Password style Dialogs and validate the password in Active Directory [Dynamics AX, X++]

This post will be helpful in creating the dialogs with the password style dialog fields in it.
Also, once the passwords have been provided by the user, the code will validate the password of the current logged in user in the active directory and will provide the relavant messages accordingly.

Note: AxaptaUserManager class is used to validate the password.This class is also helpful to generate passwords, validate domain etc.

Below is how the dialog looks with password style dialog fields.


static void SR_PasswordDialogs_validateADUser(Args _args)
{
Dialog d = new Dialog(“Password style dialogs and validate password in Active directory”);
DialogField dfPass1, dfPass2;

UserInfo userInfo;
AxaptaUserManager axUserManager;
;

dfPass1 = d.addField(typeid(password), “Enter password”, “Enter password.”);
dfPass2 = d.addField(typeid(password),”Re-enter password”, “Re-enter your password to validate”);

dfPass1.passwordStyle(true);
dfPass2.passwordStyle(true);

if (d.run())
{
userInfo = xUserInfo::find(false, curuserId());
axUserManager = new AxaptaUserManager();

if (strcmp(dfPass1.value(), dfPass2.value()))
throw error(“@SYP1505”);

if (axUserManager.validatePassword(userInfo.networkAlias , userInfo.NetworkDomain, dfPass1.value()))
{
info(“Password matches with the Active directory password :)”);
}
else
{
warning (“Password doesn’t match with the Active directory password :(“);
}
}
}

Good day!!

One Response to “Password style Dialogs and validate the password in Active Directory [Dynamics AX, X++]”

  1. Haus Fay Hotel Says:

    I was suggested this blog by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my difficulty.
    You’re incredible! Thanks!


Leave a comment