C#验证AD账号是否存在
public bool CheckUserExist(string userName) { IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); using (var domainContext = new PrincipalContext(ContextType.Domain, ipGlobalProperties.DomainName)) { using (var foundUser = UserPrincipal.FindByIdentity(domainContext, IdentityType.SamAccountName, userName)) { return foundUser != null; } } }

浙公网安备 33010602011771号