How to query a user based on extensionAttributes?

Brecht Ghijselen 20 Reputation points
2024-12-06T11:04:38.44+00:00

I want to query a user by the value of extensionAttribute1 but I'm getting this error: "Microsoft.Graph.Models.ODataErrors.ODataError: Property 'extensionAttribute1' does not exist as a declared property or extension property." When I go to my own user in Entra, I can clearly see my extensionattributes are filled in: entra-extension-attributes

This is the code I'm using to make the request:

UserCollectionResponse? response = await _graph.Users.GetAsync(requestConfiguration =>
{
    requestConfiguration.QueryParameters.Filter = "extensionAttributes/extensionAttribute1 eq '<MY-VALUE>'";
    requestConfiguration.QueryParameters.Count = true;
    requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
});```

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,265 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,341 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
23,660 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 45,761 Reputation points
    2024-12-09T08:21:41.2233333+00:00

    Hi @Brecht Ghijselen

    It should be onPremisesExtensionAttributes attribute instead of extensionAttributes.

    User's image

    It is working for me:

    User's image

    Hope this helps.

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

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Vasil Michev 115.3K Reputation points MVP
    2024-12-06T16:17:04.31+00:00

    Graph refers to these as onPremisesExtensionAttributes: https://learn.microsoft.com/en-us/graph/api/resources/onpremisesextensionattributes?view=graph-rest-1.0

    So you need to use the correct filter:

    GET https://graph.microsoft.com/v1.0/users?$filter=onPremisesExtensionAttributes%2FextensionAttribute7 eq %27IsManager%27&$count=true
    
    1 person found this answer helpful.
    0 comments No comments

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.