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



我想通过图形api或sdk为整个b2c实例创建'用户自定义属性'。就像我通过Azure Portal遵循下面引用的ms文档一样。

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指定为"用户"。

一个例子:

Post https://graph.microsoft.com/v1.0/applications/{object id of the Azure AD application}/extensionProperties
{"name":"customAttribute","dataType":"string","targetObjects":["User"]}

将生成一个名为extension_{client id of the Azure AD application without "-"}_customAttribute的扩展属性。

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

Patch https://graph.microsoft.com/v1.0/users/{user id}
{"extension_{client id of the Azure AD application without "-"}_customAttribute":"value"}

请注意:

您在Azure Portal上创建的用户自定义属性与名为b2c-extensions-app. Do not modify. Used by AADB2C for storing user data.的Azure AD应用程序相关联您可以在Azure AD B2C找到它→<<strong>应用程序注册/strong>→.

但是你使用Microsoft Graph创建的自定义属性不会出现在Azure Portal | User attributes无论您是否在b2c-extensions-app或任何其他Azure AD应用程序下创建自定义属性。

最新更新