How to validate domain credentials?

前端 未结 5 2093
闹比i
闹比i 2020-11-27 10:04

I want to validate a set of credentials against the domain controller. e.g.:

Username: STACKOVERFLOW\\joel
Password: splotchy

Method 1. Qu

5条回答
  •  渐次进展
    2020-11-27 10:31

    C# in .NET 3.5 using System.DirectoryServices.AccountManagement.

     bool valid = false;
     using (PrincipalContext context = new PrincipalContext(ContextType.Domain))
     {
         valid = context.ValidateCredentials( username, password );
     }
    

    This will validate against the current domain. Check out the parameterized PrincipalContext constructor for other options.

提交回复
热议问题