Using Microsoft graph API to retrieve a specific a

2019-06-09 14:31发布

Hi (i'm new to this so you'll need to forgive me),

I'm trying to use Microsoft Graph API to retrieve some user attributes from active directory.

I'm conducting some testing on Microsoft graph explorer but i'm not entirely sure how to retrive a specific attribute called employeeID (which is needed). I've found out how to retrive some of the other basic information i need using the following:

https://graph.microsoft.com/v1.0/me

Which returns:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
    "id": "6df92a63-2bef-477c-8c84-bf1113d5bd3e",
    "businessPhones": [],
    "displayName": "SmithB",
    "givenName": "bob",
    "jobTitle": null,
    "mail": "example@example.com",
    "mobilePhone": null,
    "officeLocation": null,
    "preferredLanguage": null,
    "surname": "smith",
    "userPrincipalName": "example@example.com"
}

However, i'm at a loss beyond this point. The docs seem to mention something about using $select but it seems to be more for refining a query rather than finding a specific attribute.

I'm sure there is a fairly simple solution and would appreciate if someone could point me in the right direction for how to query a specific attribute.

1条回答
对你真心纯属浪费
2楼-- · 2019-06-09 14:59

If you look at the documented properties exposed on a user, you will find there is no property called EmployeeId.

Now it could be that this property exists as an Open Extension on the user object.

In that case you can read here on how to return the extension properties for the user object.

GET /users/{Id|userPrincipalName}/extensions/{extensionId}

Or you could be using Schema Extensions for the same purpose.

GET https://graph.microsoft.com/beta/schemaExtensions

Either way, if you are certian that EmployeeId exists in your directory, you should know it is NOT a default property that is supported by Microsoft Graph or AAD. Instead it must be some extension that was added to your directory with one of the two extension methods above.

I hope this helps.

查看更多
登录 后发表回答