azure - 通过graph api或graph sdk为整个B2C实例创建用户自定义属性

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

我想通过图形 API 或 SDK 为整个 B2C 实例创建“用户自定义属性”。就像我通过 Azure Portal 按照 ms documentation 所做的那样引用如下。

1. Sign in to the Azure portal as the global administrator of your Azure AD B2C tenant.
2. Make sure you're using the directory that contains your Azure AD B2C tenant by switching to it in the top-right corner of the Azure portal. 
3. Select your subscription information, and then select Switch Directory.
4. Choose All services in the top-left corner of the Azure portal, search for and select Azure AD B2C.
5. Select User attributes, and then select Add.
6. Provide a Name for the custom attribute (for example, "ShoeSize")
7. Choose a Data Type. Only String, Boolean, and Int are available.
8. Optionally, enter a Description for informational purposes.
9. Click Create.

需要明确的是,我不想创建具有自定义属性的用户,而是为 b2c 中的所有用户创建自定义属性。

我可以这样做吗?如果可以,怎么做?

最佳答案

您可以使用Create extensionProperty为整个 B2C 实例创建“用户自定义属性”。

请注意,我们需要将 targetObjects 指定为“User”。

一个例子:

Post https://graph.microsoft.com/v1.0/applications/{object id of the Azure AD application}/extensionProperties

{"name":"customAttribute","dataType":"string","targetObjects":["User"]}

它将生成一个名为 extension_{Azure AD 应用程序的客户端 ID,不带“-”}_customAttribute 的扩展属性。

然后您可以更新任何 B2C 帐户的扩展程序属性:

Patch https://graph.microsoft.com/v1.0/users/{user id}

{"extension_{client id of the Azure AD application without "-"}_customAttribute":"value"}

请注意:

您在 Azure 门户上创建的用户自定义属性与名为 b2c-extensions-app 的 Azure AD 应用相关联。请勿修改。由 AADB2C 用于存储用户数据。您可以在 Azure AD B2C -> 应用注册 -> 所有应用程序<下找到它/strong>.

但是您使用 Microsoft Graph 创建的自定义属性不会出现在Azure Portal | 上。用户属性,无论您是在 b2c-extensions-app 下还是在任何其他 Azure AD 应用下创建自定义属性。

关于azure - 通过graph api或graph sdk为整个B2C实例创建用户自定义属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65919881/

相关文章:

azure - 如何使用用户名和密码验证 Microsoft Azure API

azure-ad-b2c - 为什么声明在我的自定义政策中被标记为不受支持?

Azure B2C 自定义策略 - 从用户旅程中的 token 写入自定义属性值

azure - 如何在 Azure 预览门户中从 Blob 存储中的包创建部署?

git - 其他 git 存储库的构建管道期间出现 Azure DevOps 错误 'Git fetch failed with exit code 128'

python - 将 python 模块添加到 AzureML 工作区

azure - Azure 自定义镜像 VM 上没有 Internet

microsoft-graph-api - OneDrive 支持的搜索查询

azure-active-directory - 如何使用 Microsoft Graph API 获取用户上次登录日期?

mysql - 将Web表单数据提交到MySQL数据库表时如何获取登录Azure B2C用户的id?