Skip to main content
added 203 characters in body
Source Link
Quirijn
  • 6.8k
  • 1
  • 14
  • 33

Update

If Peter is correct, my answer makes no sense of course! I will leave it for now until Hiren has confirmed that the group memberships are indeed expanded automatically.

Original answer

As far as I know, the only way to do this is to go through the group memberships recursively. For example (untested code!!)

TrusteeData trustee = (TrusteeData) client.Read(TrusteeID, new ReadOptions());
List<GroupMembershipData> groupMemberships = GetGroupMemberships (trustee);

private List<GroupMembershipData> GetGroupMemberships (TrusteeData trustee) 
{
    List<GroupMembershipData> memberships = new List<GroupMembershipData>();
    foreach (GroupMembershipData groupMshpData in trustee.GroupMemberships)
    {
        memberships.Add(groupMshpData.Group);
        subMemberships = GetGroupMemberships(groupMshpData.Group);
        if (subMemberships.Count > 0)
            memberships.AddRange(subMemberships);
    }
    return memberships;
}

As far as I know, the only way to do this is to go through the group memberships recursively. For example (untested code!!)

TrusteeData trustee = (TrusteeData) client.Read(TrusteeID, new ReadOptions());
List<GroupMembershipData> groupMemberships = GetGroupMemberships (trustee);

private List<GroupMembershipData> GetGroupMemberships (TrusteeData trustee) 
{
    List<GroupMembershipData> memberships = new List<GroupMembershipData>();
    foreach (GroupMembershipData groupMshpData in trustee.GroupMemberships)
    {
        memberships.Add(groupMshpData.Group);
        subMemberships = GetGroupMemberships(groupMshpData.Group);
        if (subMemberships.Count > 0)
            memberships.AddRange(subMemberships);
    }
    return memberships;
}

Update

If Peter is correct, my answer makes no sense of course! I will leave it for now until Hiren has confirmed that the group memberships are indeed expanded automatically.

Original answer

As far as I know, the only way to do this is to go through the group memberships recursively. For example (untested code!!)

TrusteeData trustee = (TrusteeData) client.Read(TrusteeID, new ReadOptions());
List<GroupMembershipData> groupMemberships = GetGroupMemberships (trustee);

private List<GroupMembershipData> GetGroupMemberships (TrusteeData trustee) 
{
    List<GroupMembershipData> memberships = new List<GroupMembershipData>();
    foreach (GroupMembershipData groupMshpData in trustee.GroupMemberships)
    {
        memberships.Add(groupMshpData.Group);
        subMemberships = GetGroupMemberships(groupMshpData.Group);
        if (subMemberships.Count > 0)
            memberships.AddRange(subMemberships);
    }
    return memberships;
}
Source Link
Quirijn
  • 6.8k
  • 1
  • 14
  • 33

As far as I know, the only way to do this is to go through the group memberships recursively. For example (untested code!!)

TrusteeData trustee = (TrusteeData) client.Read(TrusteeID, new ReadOptions());
List<GroupMembershipData> groupMemberships = GetGroupMemberships (trustee);

private List<GroupMembershipData> GetGroupMemberships (TrusteeData trustee) 
{
    List<GroupMembershipData> memberships = new List<GroupMembershipData>();
    foreach (GroupMembershipData groupMshpData in trustee.GroupMemberships)
    {
        memberships.Add(groupMshpData.Group);
        subMemberships = GetGroupMemberships(groupMshpData.Group);
        if (subMemberships.Count > 0)
            memberships.AddRange(subMemberships);
    }
    return memberships;
}