如何在安卓应用中访问 graph.windows.net Microsoft Azure Graph API?



我已要求我的 IT 管理员以目录扩展的形式将一个名为EmployeeId的属性添加到与我们的现场 AD 同步的 Azure Active Directory。我正在尝试在给定用户登录我的安卓应用程序时为其检索此值。

我遵循了本指南,它允许我从当前登录用户的URLgraph.microsoft.com中检索数据,即名字,姓氏等。

问题是,当我运行架构扩展的 get 请求 (https://graph.microsoft.com/beta/schemaExtensions( 以尝试检索EmployeeId的值时,它只返回有关属性的一些元数据,而不是它自己的属性:

{
"id": "exti1rcdc4h_Employee",
"description": "Baker is testing extension",
"targetTypes": [
"user"
],
"status": "Available",
"owner": "XXXXXXXXXXXXXXXXXX",
"properties": [
{
"name": "EmployeeId",
"type": "Integer"
}
]
}

在做了一些研究之后,我发现我可以使用这个图形浏览器轻松检索值(通过使用 get 请求https://graph.windows.net/mydomain.com/users/user@mydomain.com(。

但是,问题是URLgraph.explorer.net似乎与上述指南不兼容。

有没有更好的方法来解决这个问题?

--编辑--

只是为了澄清我只能检索使用 Azure AD 图形资源管理器成功extension_980f32feca7d475f9e1b90a410dbee63_employeeID的值,当我访问图形资源管理器上的/users 终结点时Microsoft不会返回该值

在 GEThttps://graph.microsoft.com/v1.0/users请求中为每个用户返回的数据:

"id": "d0be2ebd-0c7b-4c10-aebe-9db4c90a9594",
"businessPhones": [],
"displayName": "username",
"givenName": "Jhon",
"jobTitle": null,
"mail": "user@mydomain.com",
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "Smith",
"userPrincipalName": "user@mydomain.com"

您在这里感到困惑源于目前有两种不同的图形 API;Microsoft Graph API 和 Azure Active Directory Graph API。

在Microsoft Graph推出之前,有几十个API,每个产品组单独发布。创建Microsoft图形 API 是为了将这些合并到单个终结点中。显然,这是一项不平凡的努力Microsoft因此Graph在过去几年中一直在吸收API。其中一个吸收的API是Azure Active Directory Graph API。

您正在寻找的 API 是 Microsoft 图形 API。特别是我,您正在寻找这些架构扩展。

至于从Android访问API,您很可能希望使用适用于Android的Microsoft Graph SDK。还有一些可用的Android示例。

是的,这是可能的。您应该能够运行几个不同的查询,例如:

  1. 查找具有特定 employeeId 的用户:

GET https://graph.microsoft.com/v1.0/users?$filter=extension_980f32feca7d475f9e1b90a410dbee63_employeeID eq 'S09655'

  1. 获取所有用户及其员工 ID(需要使用$select(

GET https://graph.microsoft.com/v1.0/users?$select=id,displayName,extension_980f32feca7d475f9e1b90a410dbee63_employeeID

此外(在积压工作中,但正在进行中(,我们正在努力将本地employeeId本机公开为userGraph 中实体上的一等属性Microsoft。不过,我还没有预计到达时间。

希望这有帮助,

最新更新