AD轻量级目录服务不验证用户

时间:2010-09-07 19:49:39

标签: authentication active-directory

出于某种原因,我无法使用LDS为在LDS中创建的用户验证用户凭据。

我的测试代码是:

        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都返回false。

LDS正在加入域的Server 2008 R2上运行。我尝试重新创建上下文,使密码过期,通过ADSI手动重置密码等等。

有什么想法吗?

1 个答案:

答案 0 :(得分:4)

我遇到了同样的问题。我所做的,并且对我有用,就是在调用ValidateCredentials时我稍微修改了用户名:

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

希望这有帮助。

相关问题