IT Pro: How to filter users in Azure AD using OData

Using OData filters are flexible when filtering Azure AD users for larger organizations.

Microsoft API supported filters

Property Name
Type
accountEnabled
Boolean
city
String
country
String
department
String
displayName
String
givenName
String
jobTitle
String
mail
String
mailNickname
String
onPremisesImmutableId
String
proxyAddresses
String collection
state
String
surname
String
usageLocation
String
userPrincipalName
String
userType
String

For more details about these properties, click on the Microsoft link below and search 'Supports $filter'. Only the properties marked with 'Supports $filter' are supported in Microsoft Graph API.
https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/user#properties

Logical Operators

The logical operators supported are shown in the following table.

eq
Equal
city eq 'Atlanta'
and
Logical and
city eq 'Atlanta' and city eq 'London'
or
Logical or
city eq 'Atlanta' or city eq 'London'
startswith
Starts with
startswith(mail, 'administrator@')

Note: The following $filter operators are not supported for Azure AD resources: ne, gt, ge, lt, le, and not. The contains string operator is currently not supported on any Microsoft Graph resources. See Microsoft Reference.

OData examples

Return all users in one country.

country eq 'United Kingdom'


Return all users in from multiple countries

country eq 'New Zealand' or country eq 'Australia' or country eq 'NZ' or country eq 'AU'


Returns all users that are enabled from multiple cities and multiple departments

accountEnabled eq true and (department eq 'Marketing' or department eq 'HR' or department eq 'IT Support' or department eq 'Customer Services' or city eq 'Atlanta' or city eq 'New york' or city eq 'Los Angeles')

Returns certain users within a Department that are enabled.

accountEnabled eq true and department eq 'Technology' and (startswith(jobTitle,'IT') or  startswith(jobTitle,'Technology'))

Returns all users with city equal to London or New York

city eq 'London' or city eq 'New York' 


General filter that will returns only user accounts that are not disabled and has job title

accountEnabled eq true

Learn more:

IT Pro: How to filter users in Azure AD using Client-Side.

IT Pro: How to Sync Custom Attribute of Azure AD to Xink Portal (Hybrid AAD)


OData expression syntax for filters and order-by clauses in Azure Search:
https://docs.microsoft.com/en-us/rest/api/searchservice/odata-expression-syntax-for-azure-search


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.