Christian B
Christian B

Reputation: 21

How to get all users - I only get admins?

I'm trying to get a list of all users in my organization (~300), but the /users endpoint only returns two admin accounts.

Our administrator has given the application consent.

Scope: https://graph.microsoft.com/.default

Does it have something to do with the "(Admin only)" marking on the screenshot below?

enter image description here

/v1.0/users returns:

enter image description here

Upvotes: 1

Views: 243

Answers (1)

Karlheinz Reinhardt
Karlheinz Reinhardt

Reputation: 1075

Some permissions do require an Admin Consent and thus have the marking "(Admin only)".
"Admin only" means that only an administrator can consent this permission.
Most delegated permissions (access on behalf a user) do not need an Admin consent, but some like e.g. Agreement.Read.All are only available for administrators.

enter image description here

Since you are using Application Permissions (and getting access without a user) all permissions will have the "(Admin only)" mark. But this does not mean that the returned results are limted to admins.

Seeing you have given the app the permission User.Read.All your app should be able to request a list of all Users with /v1.0/users/ (it will definitely return all users).

The most likely explanation for your results is that you only have two users in your Office365 AD.
Maybe there was an error setting up the users?
I would suggest to login into the Graph-Explorer and check if you get the same results. And to check in your Azure Admin Portal if all users registered in your AD.

Upvotes: 1

Related Questions