C# 验证输入的Account是不是域合法的用户,组或机器。(User, Group, Machine)
Principal accountInfo; using (PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domain)) { accountInfo = Principal.FindByIdentity(ctx, name); } if (accountInfo == null) { return false; } AccountType accountType
if (accountInfo is UserPrincipal) { accountType = AccountType.User; } else if (accountInfo is GroupPrincipal) { accountType = AccountType.Group; } else { accountType = AccountType.Machine; }