Active Director Domain AD域验证
public bool checkADGroup(string initial) { string ADGroup = "IT-Support";//域内组名 string Domain = "xx.xxxxx.net";//域名 if (ADGroup == "NA") { return true; } string container = Domain.Replace(".", ",DC="); PrincipalContext domainctx = new PrincipalContext(ContextType.Domain, Domain.Split('.')[0], "DC=" + container); UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(domainctx,IdentityType.SamAccountName,initial); bool isMember = userPrincipal.IsMemberOf(domainctx,IdentityType.Name,ADGroup); return isMember; }