Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Extended Properties on User using Microsoft Graph

I am working with Microsoft Graph to manage Azure AD users and am having some trouble accessing extension properties on a User object. The property was added when the user was created using Azure AD Graph API and if you query the user using Azure AD API the extension property is automatically returned with the name “extension_{appId}_{propertyName}”. I would like to access the value of this property using Microsoft Graph but haven’t found the correct call to do so.

I have tried using $select to select the property directly (by the full name listed above) and the shorter name.
https://graph.microsoft.com/beta/Users/{id}?$select=extension_{appId}_{propertyName}

I have also tried querying the singleValueExtendedProperty (and multiValue) with $expand but am told the property does not exist on a User object.
https://graph.microsoft.com/beta/Users/{id}?$expand=singleValueExtendedProperty

I have also played around with the 'extensions' field on the User object but that is always just null.

Just curious if Graph supports this operation and if so, how to query that field. It would be a bonus if I could get the value of this extension when querying for groups of users without having to run a separate query.

like image 756
J Lauzon Avatar asked Aug 28 '17 18:08

J Lauzon


1 Answers

Extensions show up in Microsoft Graph within the Extensions collection, not are top-level properties:

"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,displayName,mail,extensions)/$entity",
"id": "16f5a7b6-5a15-4568-aa5a-31bb117e9967",
"displayName": "Anne Weiler",
"mail": "[email protected]",
"[email protected]": "https://graph.microsoft.com/v1.0/$metadata#users('16f5a7b6-5a15-4568-aa5a-31bb117e9967')/extensions",
"extensions": [
    {
        "@odata.type": "#microsoft.graph.openTypeExtension",
        "theme": "dark",
        "color": "purple",
        "lang": "Japanese",
        "extensionName": "com.contoso.roamingSettings",
        "id": "com.contoso.roamingSettings"
    }
]

For example, you can use the following query to return a collection of users (including any extensions): v1.0/users?$select=id,displayName,mail&$expand=extensions (see in Graph Explorer)

like image 102
Marc LaFleur Avatar answered Oct 30 '22 16:10

Marc LaFleur