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);
}

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 法蘭克不要怕 的頭像
    法蘭克不要怕

    法蘭克不要怕

    法蘭克不要怕 發表在 痞客邦 留言(0) 人氣()