Search code examples
active-directoryazure-active-directorymicrosoft-graph-api

Microsoft Graph AD Users or people API to search all users?


I'm trying to build functionality into my app for 'admins' to assign users from their AD group to certain groups that are further assigned to app-specific roles. Basically a simple management component.

Adding the user with the oid to a group is easy, the problem I'm facing is finding the actual user.

Currently, the only option I'm seeing is making multiple api requests to v1.0/users (999 items max) and grouping them all in memory and then provide a simple search function to narrow it down.

I have also used the v1.0/me/people endpoint to search for users but this does not reveal all users from the AD group, just relevant users they deal with, so not too useful.

Is there any other api endpoint I could tap into to do a search ONLY on members of the same active directory?


Solution

  • Using the startsWith filter on multiple properties is probably the closest we can get to user search in MS Graph at the moment:

    https://graph.microsoft.com/v1.0/users?$filter=startswith(displayName,'sarah') or startswith(givenName,'sarah') or startswith(surname,'sarah') or startswith(mail,'sarah') or startswith(userPrincipalName,'sarah')