microsoft-graph-api - 使用Microsoft Graph在用户上获取扩展属性

标签 microsoft-graph-api azure-ad-graph-api

我正在使用Microsoft Graph来管理Azure AD用户,并且在访问User对象上的扩展属性时遇到了一些麻烦。使用Azure AD Graph API创建用户时添加了该属性,并且如果使用Azure AD API查询用户,则扩展属性将自动返回,名称为“extension_ {appId} _ {propertyName}”。我想使用Microsoft Graph访问此属性的值,但没有找到正确的调用。

我尝试使用$ select直接选择属性(通过上面列出的全名)和简称。
https://graph.microsoft.com/beta/Users/{id}?$select=extension_{appId}_{propertyName}

我也尝试使用$ expand查询singleValueExtendedProperty(和multiValue),但被告知该属性在User对象上不存在。
https://graph.microsoft.com/beta/Users/{id}?$expand=singleValueExtendedProperty

我还使用了User对象上的“扩展”字段,但始终始终为null。

只是好奇Graph是否支持此操作,如果支持,如何查询该字段。如果在查询用户组而不必运行单独的查询时可以得到此扩展的值,那将是一个好处。

最佳答案

扩展名显示在Extensions集合内的Microsoft Graph中,不是顶级属性:

"@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": "annew@CIE493742.onmicrosoft.com",
"extensions@odata.context": "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"
    }
]
例如,您可以使用以下查询返回users(包括任何扩展名)的集合:v1.0/users?$select=id,displayName,mail&$expand=extensions(请参见Graph Explorer中的内容)

关于microsoft-graph-api - 使用Microsoft Graph在用户上获取扩展属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45925030/

相关文章:

office365 - 通过代码新创建的 Azure AD 应用程序不会生成具有所需角色的 token

microsoft-graph-api - 为 OneDrive Business 创建订阅返回 403 禁止

azure - 如何将所有者添加到 Azure Active Directory 应用程序

azure-ad-graph-api - Microsoft Graph Api-更改密码

office365 - 用于 onPremisesExtensionAttributes 的 Microsoft Graph 过滤器

azure - 使用 Graph API 读取 Azure B2C 自定义属性

c# - Microsoft Graph Beta - 从 EwsId 转换为 RestId 或 RestImmutableEntryId

azure - 使用 Graph Api 更新 Azure Active Directory 应用程序的应用程序角色

azure - 将 AuthenticationContext 和 ActiveDirectoryClient 与应用程序代理一起使用?

azure - 如何从 B2C 用户记录中读取移动值并将其转换为 StrongAuthenticationPhoneNumber?