0
  
  using(PrincipalContext cntx = new PrincipalContext(
        ContextType.Domain, "blah.corp.net:389", "OU=customers,OU=web,CN=blah,CN=corp,CN=net", 
        ContextOptions.Negotiate, "Domin\Admin", "{Password}")){
        string password = "PPaass00!!";
        UserPrincipal p = new UserPrincipal(cntx);
        p.SamAccountName = "GuestUser";
        p.PasswordNeverExpires = true;
        p.Enabled = true;
        p.SetPassword(password);
        p.Save();
        bool b = cntx.ValidateCredentials("GuestUser", password); //where b always false
    }

我不明白为什么 b 总是假的。任何人都可以帮忙吗?

4

1 回答 1

0

虽然我不知道您的问题的答案,但您是否尝试过这种方法?

PrincipalContext cntx = new PrincipalContext(ContextType.Domain, 
    "blah.corp.net:389", 
    "OU=customers,OU=web,CN=blah,CN=corp,CN=net",ContextOptions.Negotiate, 
    "Domin\GuestUser", password)

在它周围放置一个try/catch,看看它在你连接时是否抛出异常。

于 2011-06-21T14:44:32.567 回答