Using Microsoft graph API to retrieve a specific attribute

好久不见. 提交于 2019-12-08 04:17:51

问题


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:


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.




回答2:


I guess this thread is pretty outdated. There is now a standard attribute in Azure AD exposed via Microsoft Graph API called "employeeId" as documented on Official GraphAPI reference doc It is not presented in the default response, but can be retrieved by $select argument like: https://graph.microsoft.com/v1.0/users/{user_id}?$select=givenName,surname,employeeId,etc...



来源:https://stackoverflow.com/questions/43808086/using-microsoft-graph-api-to-retrieve-a-specific-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!