简体   繁体   English

对于空白密码,PrincipalContext.ValidateCredentials返回什么?

[英]What does PrincipalContext.ValidateCredentials return true for blank passwords?

We have a login box for our app that asks the user to enter their AD credentials. 我们为应用程序提供了一个登录框,要求用户输入其AD凭据。 We take those credentials and then call 我们获取这些凭据,然后致电

    using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, domain, container, ContextOptions.SimpleBind))
    {
        return pc.ValidateCredentials(domain + @"\" + username, password, ContextOptions.SimpleBind);
    }

to validate that they've entered a valid login/password pair. 验证他们是否输入了有效的登录名/密码对。 What we found out though, was that the call to ValidateCredentials will return true with a blank password, and we have no idea why. 但是我们发现,对ValidateCredentials的调用将使用空白密码返回true,而我们不知道为什么。 An invalid password returns false, but blank will return true as long as the username is correct. 无效的密码返回false,但是只要用户名正确,空白密码将返回true。

From MSDN http://msdn.microsoft.com/en-us/library/bb154889.aspx 从MSDN http://msdn.microsoft.com/en-us/library/bb154889.aspx

The ValidateCredentials method binds to the server specified in the constructor. ValidateCredentials方法绑定到构造函数中指定的服务器。 If the username and password parameters are null, the credentials specified in the constructor are validated. 如果username和password参数为null,则验证构造函数中指定的凭据。 If no credential were specified in the constructor, and the username and password parameters are null, this method validates the default credentials for the current principal. 如果在构造函数中未指定凭据,并且username和password参数为null,则此方法将验证当前主体的默认凭据。

In the PrincipalContext constructor you could specify the credentials you want to check as well. 在PrincipalContext构造函数中,您也可以指定要检查的凭据。

using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, domain, 
                       container, ContextOptions.SimpleBind, username, password))
{
    return pc.ValidateCredentials(domain + @"\" + username, password,
                                   ContextOptions.SimpleBind);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PrincipalContext.ValidateCredentials方法中的“有效”是什么意思? - What is “valid” meaning in PrincipalContext.ValidateCredentials method? C#中具有缓存凭据的PrincipalContext.ValidateCredentials - PrincipalContext.ValidateCredentials with cached credentials in C# PrincipalContext.ValidateCredentials:查找用户名或密码无效 - PrincipalContext.ValidateCredentials: find username or password is invalid PrincipalContext.ValidateCredentials始终返回FALSE - PrincipalContext.ValidateCredentials always returns FALSE 某些用户的 PrincipalContext.ValidateCredentials 失败? - PrincipalContext.ValidateCredentials fails for some users? Active Directory PrincipalContext.ValidateCredentials域消除歧义 - Active Directory PrincipalContext.ValidateCredentials domain disambiguation 使用NetBios名称,PrincipalContext.ValidateCredentials在受信任域中变慢 - PrincipalContext.ValidateCredentials slow with trusted domain using NetBios name PrincipalContext.ValidateCredentials 调用如何在 DC 上注册或标记? - How is PrincipalContext.ValidateCredentials call registered or marked on DC? 为什么PrincipalContext.ValidateCredentials针对旧凭据进行验证? - Why is PrincipalContext.ValidateCredentials validating against old credentials? PrincipalContext.ValidateCredentials不会为用户设置lastLogon日期 - PrincipalContext.ValidateCredentials doesn't set lastLogon date for user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM