Is there a Graph API to get the count of members of a specific type from AAD group? For example, consider the following AAD group:
This group contains 2 members of type 'Group'. Is there a Graph API to get that count (2)? Or should I get all members from the group and do some filtering to get the members of 'Group' type as follows:
var groups = new List<Guid>();
var response = await _graphServiceClient
.Groups[groupId]
.TransitiveMembers
.Request()
.Top(999)
.GetAsync();
groups.AddRange(ToGroups(response));
private IEnumerable<Guid> ToGroups(IEnumerable<DirectoryObject> members)
{
foreach (var directoryObj in fromGraph)
{
switch (directoryObj)
{
case Group group:
yield return Guid.Parse(group.Id);
break;
default:
break;
}
}
}
