问题描述
我有一个 Azure AD 租户,我正在寻找一种在组织内创建成员时包含额外属性的方法。我已经浏览了界面,但找不到在 Azure 门户上实现此目的的方法。从我的发现中,我可以看到有关如何使用 B2C 功能和图形 API 为外部客户实现这一目标的文档和博客文章的基调。但是,这不符合我的要求。
我相信这是 Azure AD 上应该可以实现的基本要求。有人可以指出我正确的文档来实现这一目标吗?
解决方法
Azure 门户不提供此类功能,但我们可以使用 Microsoft Graph API 将其存档:Create extensionProperty。
您需要将 targetObjects
指定为“用户”。
示例(您可以使用您的任何应用注册来注册 {object id of the app registration}
):
Post https://graph.microsoft.com/v1.0/applications/{object id of the app registration}/extensionProperties
{"name":"customAttribute","dataType":"string","targetObjects":["User"]}
它将生成一个名为 extension_{client id of the app registration without "-"}_customAttribute
的扩展属性。
然后您可以更新用户的扩展属性:
Patch https://graph.microsoft.com/v1.0/users/{user id}
{"extension_{client id of the Azure AD application without "-"}_customAttribute":"value"}