Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

AX 2012 - Validation in Active Directory with x++

(0) ShareShare
ReportReport
Posted on by 10

Hello all,

i'va have a issue with one user when he want to validate his credentials, with all others it works. Here the method

 str                                                             userName    = System.Environment::get_UserName(),
                                                                    userDomain  = System.Environment::get_UserDomainName();

    System.DirectoryServices.AccountManagement.PrincipalContext     pc;

    ;

    dfUser = d.addFieldValue(extendedTypeStr(UserIdStr), strFmt(@"%1\%2", userDomain, userName));

    dfPass = d.addFieldValue(extendedTypeStr(password),"");

    dfUser.enabled(false);

    dfPass.passwordStyle(true);

    if (d.run())
    {
        pc = new System.DirectoryServices.AccountManagement.PrincipalContext(
                                                                                System.DirectoryServices.AccountManagement.ContextType::Domain,
                                                                                userDomain
                                                                            );

        //Invalid Password
        if(!pc.ValidateCredentials(userName, dfPass.value()))  return checkFailed("@EVE4195");

        return true;

    }

I don't know how to retrieve any exception, only returns false.

I did a Tester with C# with the same code and it work's.

Thanks in advance!

  • André Arnaud de Calavon Profile Picture
    294,261 Super User 2025 Season 1 on at
    RE: AX 2012 - Validation in Active Directory with x++

    Hi igallegoferreira,

    Were you able to verify the last reply from Will? Do you need any assistance or has your question been solved in the meantime?

  • WillWU Profile Picture
    22,352 on at
    RE: AX 2012 - Validation in Active Directory with x++

    Hi igallegoferreira,

    Please make sure the user is a AX user:

    docs.microsoft.com/.../create-new-users-in-microsoft-dynamics-ax

    And you could use class xAxaptaUserManager to validate the password:xAxaptaUserManager.validatePassword.

  • igallegoferreira Profile Picture
    10 on at
    RE: AX 2012 - Validation in Active Directory with x++

    Hi André, thanks for your reply,

    The same code works for other users, and the dfUser is the combination of  userDomain+ userName, dfPass is the hidden password entered by user.

    The problem is with the validation in "pc.ValidateCredentials()", that only returns false. With the tester i did in C#, this user can Login succesfully.

    Thanks in advance.

  • André Arnaud de Calavon Profile Picture
    294,261 Super User 2025 Season 1 on at
    RE: AX 2012 - Validation in Active Directory with x++

    Hi,

    Can you explain if the same code works for all other users? When is this coding executed? It seems like you didn't put the full coding above. Or something else is missing. E.g. what is dfUser and dfPass?

    Why do you need to validate credentials in AX 2012? When the user logs in on his PC he will have to provide his credentials already.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,996 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans