Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Unanswered

AX 2012 - Validation in Active Directory with x++

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
    André Arnaud de Cal... 287,914 Super User 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
    WillWU 22,344 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
    igallegoferreira 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
    André Arnaud de Cal... 287,914 Super User 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.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,914 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,549 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans