新创建的用户无法验证
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 总是假的。有人可以帮忙吗?
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
}
I don't understand why b is always false. Can anyone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
虽然我不知道你问题的答案,但你尝试过这种方法吗?
在它周围放置一个 try/catch,看看它在连接时是否抛出异常。
While I don't know the answer to your question, have you tried this method instead?
Put a try/catch around it and see if it throws an exception when you connect or not.