C# – ADAM authentication w/ ADAM user and simple bind

active-directoryadamauthenticationc

I've followed the ADAM Step by Step Guide from Microsoft and setup an ADAM instance on my local machine. I'm attempting to authenticate using the "Mary Baker" account, but every time I get a COM exception on the if (entry.Guid != null) line below. The exception states that there's an unknown user name or bad password.

However, I can use the ldp utility to connect to ADAM and successfully perform a simple bind – so I know that the user name both exists, and I have the correct password.

Additionally, I have set the msDS-UserAccountDisabled property on the user to false, and added the user to both the Administrators and Readers roles.

Any thoughts?

    path = "LDAP://localhost:50000/O=Microsoft,c=US";
    userId = "CN=Mary Baker,OU=ADAM users,";
    password = "Mary@101";

    DirectoryEntry entry = new DirectoryEntry(path, userId, password, AuthenticationTypes.None);
    if (entry.Guid != null)
        LoadWelcomeScreen();

Thanks.

Best Answer

ADAM stores the unique identifier for a user in the displayName attribute of the user class. They need to be unique in the ADAM instance for the user to authenticate. If two users both had their displayName attribute set to 'jsmith' then neither user could authenticate in ADAM.

Use the ldp utility to query the displayName for Mary Baker. It could be something like 'mbaker'. Use that value as the userId in the given code.