Email Signature Platform - Help Desk and Knowledge Base

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 eg 'Atlanta'
ne
Not equal
city ne 'London'
gt
Greater than
postalCode gt 30300
ge
Greater than or equal
postalCode ge 30301
lt
Less than
postalCode lt 30300
le
Less than or equal
postalCode le 30301
and
Logical and
city eg 'Atlanta' and city eg 'London'
or
Logical or
city eg 'Atlanta' or city eg 'London'
not
Logical negation
not endswith(mail,'xink.co.uk')
endswith
Ends with
endswith(mail, 'xink.io')
startswith
Starts with
startswith(mail, 'administrator@')

OData examples

Return all users in one country.

country eq 'United Kingdom'

Returns all users with city equal Atlanta and department equal IT.

city eq 'Atlanta' and department eq 'IT'

Returns all users with city equal London or Atlanta and department is not Marketing.

city eq 'London' or city eq 'New York' and department ne 'Marketing'

Returns all users with country equal the United Kingdom and email ends with xink.co.uk.

country eq 'United Kingdom' and endswith(mail, '@xink.co.uk')


Learn more:

https://docs.microsoft.com/en-us/rest/api/searchservice/odata-expression-syntax-for-azure-search

Quick Demo  

Did you find it helpful? Yes No

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