Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

There may be some cases where you would like to filter the Azure AD records for Users and Groups. Some example cases can be listed as follows:

...

The filters need to be formatted according to Microsoft Graph API requirements. You may find some examples below. Please refer to Microsoft Graph API documentation for more details.

NameaccountEnabled eq true

Description

Filter

Filter

To list only Microsoft 365 groups (aka unified groups), apply a filter on groupTypes:

Group

groupTypes/any(c:c+eq+'Unified')

Only import Groups starting with “corp”.

Group

startswith(displayName, 'corp')

Only the active users.

Users

Import only the active users.

accountEnabled eq true

Import the users based in London city.

city eq 'London'

Import users in a country.

country eq 'Ecuador'

Import users of two countries.

country eq 'Ecuador' or country eq 'India'

Import users of multiple countries.

country in ('Ecuador', 'India', 'Germany')

Import users which are having userType as Member

userType eq 'Member'

Import only Engineering department

department eq 'Engineering'

Note: When using the in operator, the request is limited to 15 expressions in the filter clause. More information.

It is not possible to filter according to all the attributes or use all the filter operators. The following examples will not work with the filters due to the limitations of Microsoft Graph API. More information.

Description

Filter

Only the users having the organization's email address.

Users

endsWith(mail,'@organization.com')

Users having an email address.

NOT(mail eq null)

Another way to filter users having an email address.

mail ne null

Import only if the users have a company name that is not Microsoft.

Users

companyName ne null and NOT(companyName eq 'Microsoft')

Do not import the users starting with Conf.

Users

NOT startsWith(displayName, 'Conf')

Do not import the users having user type as Guest

not(userType in ('Guest'))