Get users via MS Graph API using $search query option on directory extension properties

Igor Demjanov 1 Reputation point
2022-11-24T10:53:23.173+00:00

Hi,

I am trying to use $search query parameter to restrict the results of a MS Graph API 'Get Users' request to match a search criterion using directory extension properties, but I am not able to send a request due to an error (see first image below).

Reading documentation for Users API I am not able to see, if $search is supported or unsupported with directory extension properties.

Initially I wanted to use $filter query parameter with 'contains' operator, because I need to filter/search on a substring of a value stored in a directory extension property, but it is not supported by Users API.

$search using directory extension properties - FAILS

Request URL:
https://graph.microsoft.com/v1.0/users?$search="extension_fe2174665583431c953114ff7268b7b3_Education_ObjectType:teacher"&$select=displayName

Result:
263892-image.png

$search using default AAD properties - OK

Request URL:
https://graph.microsoft.com/v1.0/users?$search="displayName:alex"&$select=displayName

Result:
263808-image.png

$filter using directory extension properties - OK

I am able to use directory extension properties in $filter query parameter using 'eq' operator, but I need to use 'contains' operator, which is not supported by Users API.

Request URL:
https://graph.microsoft.com/v1.0/users?$filter=extension_fe2174665583431c953114ff7268b7b3_Education_ObjectType eq 'teacher'&$select=displayName

Result:
263911-image.png

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. HarmeetSingh7172 4,826 Reputation points
    2022-11-25T05:13:32.557+00:00

    Hello @Igor Demjanov

    Thanks for reaching out!

    As per the user resource type documentation, Directory and schema extensions and their associated data are returned only on $select query parameter; whereas Open extensions and their associated data are returned only on $expand query parameter.

    Refer these for more info:
    https://learn.microsoft.com/en-us/graph/extensibility-overview?tabs=http
    https://learn.microsoft.com/en-us/graph/extensibility-overview?tabs=http#directory-azure-ad-extensions
    https://learn.microsoft.com/en-us/graph/extensibility-overview?tabs=http#retrieve-a-directory-extension-property

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.


  2. CarlZhao-MSFT 46,371 Reputation points
    2022-11-25T10:07:17.24+00:00

    Hi @Igor Demjanov

    As you can see, the extended attributes of Azure AD B2C users do not support filtering with the $search parameter. The best option is still to filter with the $filter parameter, and you don't need to provide the ConsistencyLevel: eventual request header for that request, as this is not an advanced query.

    264241-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.