尝试使用 oAuth 和 REST 从 Microsoft 获取 Azure AD onPremisesSamAccountName

Trying to get Azure AD onPremisesSamAccountName from Microsoft using oAuth and REST

当我尝试通过 Microsoft Graph 和 oAuth 从 Azure AD 检索 sAMAccountName 时,未返回该属性。

我正在尝试通过 oAuth 从我的 Azure AD 租户上的 Microsoft Graph 检索 onPremisesSamAccountName。我的本地域与 Azure 同步,并且我已经 select 编辑了 sAMAccountName 目录扩展以进行同步。但是,当我向 Graph REST URI 发出 GET 请求时,我得到了正确的用户对象,但没有得到 onPremisesSamAccountName。

这是我的要求:

https://graph.windows.net/myorganization/users/user@domain.com?api_version=1.6

该请求 returns 具有大量属性的用户对象。当我尝试以下操作时(希望“$select”进入该字段,Microsoft returns 元数据 URL——实际上包含 onPremisesSamAccountName 属性 定义。

https://graph.windows.net/myorganization/users/user@somain.com?api-version=1.6&$select=onPremisesSamAccountName

我的查询格式设置不正确吗?在 Azure AD 门户中,我指定了以下 API 权限:

您可以使用 Microsoft Graph API 获取 onPremisesSamAccountName 属性。 Here 是 Microsoft Graph 资源管理器。

https://graph.microsoft.com/v1.0/users/{userObjectId}?$select=onPremisesSamAccountName

顺便说一下,您授予的权限是 Microsoft graph api 权限,而不是 Azure AD graph api 权限。 Azure AD graph is different from Microsoft Graph。推荐使用 Microsoft Graph API.