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