user145610
user145610

Reputation: 3025

Azure AD graph API to Search multiple users based on UserPrincipalName and Mail

Is there a way in Graph API where advance query able to search group of users based on Email id and User Principal Name. We are using filter parameter with "in" clause to search users https://graph.microsoft.com:443/v1.0/users?$count=true&$filter=userPrincipalName in ('[email protected]','[email protected]','guest#[email protected])

Above URL works charm. But we see Mail instead of userPrincipalName, we are decided to query based on Mail or UserPrincipalName property. Is there any support for graph api to search against Mail and UPN property in single call. I tried with signInNames or otherMails or issuerAssignedId but they are not supported. Any better way for querying both UPN and Mail

Upvotes: 3

Views: 3218

Answers (1)

Kartik Bhiwapurkar
Kartik Bhiwapurkar

Reputation: 5159

• You can use the ‘OR’ in advanced query filter parameter to search for multiple users’ based on ‘UPN’ and ‘mail’ in a single query call as below: -

https://graph.microsoft.com/v1.0/users?$count=true&$filter=mail in ('[email protected]') or userPrincipalName in ('[email protected]')

The above query will give the details of the users based on UPN as well as mail attribute and fetch the same data from Azure AD related to the users. It will fetch all the general information that is available in Azure AD.

Please find the below link for more details on using the OR operator: -

https://learn.microsoft.com/en-us/graph/query-parameters#filter-parameter

Upvotes: 4

Related Questions