Unable to retrieve custom attribute via graph API

sam nick 346 Reputation points
2023-08-25T16:23:46.0266667+00:00

Hello,

I am trying to retrieve the custom attributes for a user via graph, but cant seem to find them in the result set. Please can you advise what am i missing and how to get those values. Do i need a different query or "join" to another parameter to get the value. I am a global admin and have the attribute assignment admin.

User's image

User's image

Microsoft 365 and Office Install, redeem, activate For business Windows
Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Manu Philip 20,206 Reputation points MVP Volunteer Moderator
    2023-08-25T17:13:05.9733333+00:00

    You can try the following query to show the custom attributes for the user

    https://graph.microsoft.com/v1.0/users/******@exchangeonline.in?$select=onPremisesExtensionAttributes

    $select=displayName,onPremisesExtensionAttributes will show only the display name along with all the custom attributes


    --please don't forget to upvote and Accept as answer if the reply is helpful--

    1 person found this answer helpful.

  2. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2023-08-25T17:28:07.2466667+00:00

    You have to specifically request the custom attributes themselves, or the set as a whole. For example, this query will include all custom security attributes:

    https://graph.microsoft.com/beta/users?$select=id,displayName,customSecurityAttributes

    Do make sure that the CustomSecAttributeDefinition.Read.All scope has been consented to, and if you are running this via the Graph explorer tool (or any other method that leverages delegate permissions), that the corresponding user has sufficient permissions to access the CSA set(s) in question.

    Additional details and more examples can be found in the official documentation: https://learn.microsoft.com/en-us/azure/active-directory/enterprise-users/users-custom-security-attributes?tabs=ms-powershell


  3. Muhammad Mustafa 10 Reputation points
    2023-12-11T11:58:02.0866667+00:00

    I have also tried the following and it is working form me.

    You can try the following query to show the custom attributes for the user

    https://graph.microsoft.com/v1.0/users/******@yourTenant.com?$select=onPremisesExtensionAttributes

    this will return the following json response

    {
        "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(onPremisesExtensionAttributes)/$entity",
        "onPremisesExtensionAttributes": {
            "extensionAttribute1": "somevalue",
            "extensionAttribute2": null,
       		"extensionAttribute15": "November 12, 2023"
        }
    }
    

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.