using System.DirectoryServices.AccountManagement;
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
UserPrincipal qbeUser = new UserPrincipal(ctx);
PrincipalSearcher srch = new PrincipalSearcher(qbeUser);
List<string> ADUser = new List<string>();
foreach (var found in srch.FindAll())
{
UserPrincipal user = found as UserPrincipal;
if (user != null)
{
ADUser.Add(user.DisplayName + "," + user.Sid.ToString());
}
}
============================================
public bool CheckPassword(string userName, string password)
{
PrincipalContext adContext = new PrincipalContext(ContextType.Domain);
return adContext.ValidateCredentials(userName, password);
}