0
我正在使用下面的代码来获取组中的成员。Active Directory组成员问题
private static List<string> GetGroupMembers(string groupName)
{
Tracer.LogEntrace(groupName);
List<string> retVal = new List<string>();
GroupPrincipal groupPrincipal =
GroupPrincipal.FindByIdentity(
new PrincipalContext(ContextType.Domain),
IdentityType.SamAccountName,
groupName);
PrincipalSearchResult<Principal> principleSearchResult =
groupPrincipal.GetMembers(true);
if (principleSearchResult != null)
{
try
{
foreach (Principal item in principleSearchResult)
retVal.Add(item.DistinguishedName);
}
catch (Exception ex)
{
Tracer.Log(ex.Message);
}
}
else
{
//Do Nothing
}
Tracer.LogExit(retVal.Count);
return retVal;
}
它非常适用所有群体,但同时 枚举组发生时其来我得到以下
错误的用户组“的错误(87) 。该组的 SID无法解决。“
也许你的意思是 “域用户”,而不是 “用户” – RobSiklos 2013-08-09 15:25:17