Active Directory Group Members Issue
Posted
by kombsh
on Stack Overflow
See other posts from Stack Overflow
or by kombsh
Published on 2010-04-08T10:05:00Z
Indexed on
2010/04/08
10:33 UTC
Read the original article
Hit count: 452
active-directory
Hi friends,
I am using the below code to get the members from a group.
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;
}
It works well for all groups but when its come to Users group i am getting the below error
"An error (87) occurred while enumerating the groups. The group's SID could not be resolved."
Can any one help regarding this one.
© Stack Overflow or respective owner