1
votes

Is there a Microsoft graph API query that will list all our users with NO group membership.

I can get all the users with

 https://graph.microsoft.com/beta/users

loop over them and evaluate the groups they are members of

https://graph.microsoft.com/beta/users/{}/memberOf

and return the ones with zero group memberships. We have a large number of users so this takes time. Quicker to ask the API to return the list I want the first time.

Can I, in one query, filter on just the users that are in no groups?

1

1 Answers

0
votes

Yes, you can do that. Just try the query below:

https://graph.microsoft.com/v1.0/users?$select = userPrincipalName,displayname&$expand=memberof

With this query, you will be able to get a list that contains user data you selected with group membership data just as below:

enter image description here

So that you could filter users you want locally instead of calling APIs 1 by 1.