>在.net
中使用Active Directory安全验证用户凭据确保您的.NET应用程序的安全性需要强大的用户身份验证针对Active Directory。 System.DirectoryServices.AccountManagement
>命名空间(.NET 3.5及以后)提供了一种简化的方法。
实现:
这是对用户凭据的身份验证的方法:
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "YOURDOMAIN")) { bool isValid = pc.ValidateCredentials("myuser", "mypassword"); }
验证凭据。 在成功身份验证后将是ValidateCredentials
>
isValid
true
好处:
>直接且易于实现。
请注意,即使对于过时的用户密码,此方法也可能返回。 此行为已在其他堆栈溢出讨论中记录。>
以上是我如何在.NET中对Active Directory的用户凭据进行身份验证?的详细内容。更多信息请关注PHP中文网其他相关文章!