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总是假的。有人可以帮忙吗?
答案 0 :(得分: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,看看它是否在连接时抛出异常。