I'm using Microsoft.Graph and I want to return a list of all users in particular groups. I can not find any digestible information about this.
I have tried using .Request().Expand(x => x.Members) but this only returns 20 users. And they are not paged (see here).
I can pull a list of groups fine, but how can I filter users based on what group they're in? This is what I've got so far...
public async Task Do()
{
var graphClient = new GraphServiceClient(_authProvider);
var groups = await graphClient.Groups.Request().GetAsync();
do
{
foreach (var group in groups)
{
Console.WriteLine($"{group.Id}, {group.DisplayName}");
Console.WriteLine("------");
var filter = $""; // What goes here?
var users = await graphClient.Users.Request().Filter(filter).GetAsync();
do
{
foreach (var user in users)
{
Console.WriteLine($"{user.Id}, {user.GivenName} {user.Surname}, {user.MemberOf}");
}
}
while (users.NextPageRequest != null && (users = await users.NextPageRequest.GetAsync()).Count > 0);
Console.WriteLine();
}
}
while (groups.NextPageRequest != null && (groups = await groups.NextPageRequest.GetAsync()).Count > 0);
}