Using OData filters is a flexible and powerful way to query Entra ID (Azure AD) users, especially in larger organizations where precise targeting is essential.
Microsoft Graph API Supported Filters
The following user properties support OData filters when querying via the Microsoft Graph API:
Property Name | Type |
---|---|
accountEnabled | Boolean |
city | String |
country | String |
department | String |
displayName | String |
givenName | String |
jobTitle | String |
String | |
mailNickname | String |
onPremisesImmutableId | String |
proxyAddresses | String collection |
state | String |
surname | String |
usageLocation | String |
userPrincipalName | String |
userType | String |
For the complete list of filterable properties, visit the official Microsoft documentation and search for "Supports $filter": Microsoft Graph: User Properties
Supported Logical Operators
Below are the logical operators you can use with OData filters:
Operator | Description | Example |
---|---|---|
eq | Equals | 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 operators are not supported for Entra ID: ne
, gt
, ge
, lt
, le
, not
. Also, contains
is not supported in Microsoft Graph. See Microsoft Reference.
OData Filter Examples
Users from a specific country:
country eq 'United Kingdom'
Users from multiple countries:
country eq 'New Zealand' or country eq 'Australia' or country eq 'NZ' or country eq 'AU'
Enabled users from numerous departments and cities:
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')
Enabled users in the Technology department with particular job titles:
accountEnabled eq true and department eq 'Technology' and (startswith(jobTitle,'IT') or startswith(jobTitle,'Technology'))
Users located in London or New York:
city eq 'London' or city eq 'New York'
General filter for enabled user accounts with job titles:
accountEnabled eq true