2012-03-11 103 views

回答

1

您可以通過嘗試System.DirectoryServices.AccountManagement:

//Get NTAccount, to find out username and domen 
NTAccount nt = (NTAccount)sid.Translate(typeof(NTAccount)); 
string[] fullName = nt.Value.Split(new char[] { '\\' }); 

//then get group principle 
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, fullName[0]); 
GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, fullName[1]); 

//and check whenever this group exists 
bool SidIsAGroup = grp != null; 

您可以在此處找到類似的問題(和答案):How to get the groups of a user in Active Directory? (c#, asp.net)

0

LookupAccountSid()函數返回指示帳戶類型的SID_NAME_USE值。

相關問題