ValidateCredentials() 在第一次调用时返回 FALSE,但在后续调用时返回 TRUE
我使用以下代码对我的 Web 服务上的用户进行身份验证:
using (PrincipalContext context = new PrincipalContext(ContextType.Domain, domain))
{
return context.ValidateCredentials(userName, password);
}
我遇到的障碍是第一次调用 ValidateCredentials() 返回 false,但后续调用返回 true。我在这一行放置了一个断点,在中间窗口中我看到了相同的结果:第一个调用返回 false,第二个返回 true,即使调用之间(我)没有任何更改。
“域”是 String.Empty 但我也用实际的域名进行了尝试并得到了相同的结果。
我不太精通网络管理,所以任何帮助将不胜感激,
I'm using the following code to authenticate users on my web service:
using (PrincipalContext context = new PrincipalContext(ContextType.Domain, domain))
{
return context.ValidateCredentials(userName, password);
}
The obstacle I'm running into is that the first call to ValidateCredentials() is returning false but subsequent calls return true. I placed a breakpoint at this line and in the Intermediate window I see the same results: first call returns false, second returns true, even though nothing was changed (by me) between calls.
The 'domain' is String.Empty but I've also tried it with the actual domain name and get the same results.
I'm not that versed in network administration so any help would be appreciated,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在控制其他机器进程的程序中遇到了类似的问题。
我有一段代码在登录方法成功之前一直停滞不前:
它不能解释发生的任何情况,但它解决了我的问题......
I had the a similar problem with a program to control other machine process's.
I had a piece of code that stalls until login method succeded:
it does not explain whatever studd is happening but it solved my issue...