开发者

AD Lightweight Directory Services not Authenticating Users

开发者 https://www.devze.com 2023-01-15 18:35 出处:网络
For some reason, I cannot authenticate user credentials using LDS for users 开发者_如何学JAVAcreated in LDS.

For some reason, I cannot authenticate user credentials using LDS for users 开发者_如何学JAVAcreated 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消