您的位置:首页 > 编程语言 > C#

C# 验证输入的Account是不是域合法的用户,组或机器。(User, Group, Machine)

2012-10-22 17:21 751 查看
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;
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: