Question:
How to determine the effectiveness of the username and password of Active Directory authentication?Answer:
For applications deployed on .NET 3.5 and higher versions, System.directoryServices.accountManagement The naming space provides an efficient verification proof mechanism:
This method is simple and reliable, and it is realized in pure C#.
using(PrincipalContext pc = new PrincipalContext(ContextType.Domain, "YOURDOMAIN")) { // 验证凭据 bool isValid = pc.ValidateCredentials("myuser", "mypassword"); }
The above is the detailed content of How Can I Verify Active Directory User Credentials in C#?. For more information, please follow other related articles on the PHP Chinese website!