Home > Mobile >  How to fetch group memberships from an AAD group
How to fetch group memberships from an AAD group

Time:06-29

I'm trying to fetch all group memberships from an AAD. I have to name of the parent group I want to look for, but I need to fetch the users that are in sub groups of that parent. I've tried may things on the Microsoft docs, but I can't find the right request to find those groups.

This is a try:

var groups = await graphClient.Groups.Request().Filter($"startswith(displayName, '{Se_groupName}')").GetAsync(); //Fetch the parent group
var groupMembers = await graphClient.Groups[groups.FirstOrDefault().Id].Members.Request().GetAsync(); //Try to fetch the groups inside the first group, but its always empty

I was wondering is there a request like:

graphClient.Groups[groups.FirstOrDefault().Id].groupMemberships

CodePudding user response:

To find the nested groups and users you can use the transitiveMembers endpoint

List group transitive members

GET https://graph.microsoft.com/v1.0/groups/{groupId}/transitiveMembers

  • Related