简体   繁体   中英

AD Lightweight Directory Services not Authenticating Users

For some reason, I cannot authenticate user credentials using LDS for users created in LDS.

My test code is:

        PrincipalContext context = new PrincipalContext(ContextType.ApplicationDirectory, "adlds:50000", "CN=test,DC=test,DC=internal", ContextOptions.Negotiate);

        UserPrincipal user = new UserPrincipal(context);

        user.Enabled = true;
        user.Name = "MyTestUser";
        user.SetPassword("P@ssw0rd1");
        user.GivenName = "ATestUser123";
        user.Surname = "SurnameOf";

        user.Save();

        bool auth = context.ValidateCredentials("MyTestUser", "P@ssw0rd1");

ValidateCredentials is returning false each time.

LDS is running on Server 2008 R2 that is domain joined. I have tried recreating the context, expiring passwords, manually reseting passwords through ADSI, etc.

Any thoughts?

I've come along the same problem. What I did, and works for me, is when calling ValidateCredentials I modified the username a bit:

bool auth = context.ValidateCredentials(
                            String.Format("CN={0},CN=test,DC=test,DC=internal",
                                          "MyTestUser"), 
                            "P@ssw0rd1");

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM