通过图形 api 或图形 sdk 为整个 B2C 实例创建用户自定义属性 [英] Create user custom attribute for whole B2C instance via graph api or graph sdk

查看:13
本文介绍了通过图形 api 或图形 sdk 为整个 B2C 实例创建用户自定义属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过图形 api 或 sdk 为整个 b2c 实例创建用户自定义属性".就像我通过 Azure 门户跟随 ms 文档引用如下.

I want to create 'user custom attribute' for whole b2c instance via graph api or sdk. Just like I do thru Azure Portal following ms documentation quoted below.

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 中的所有用户创建自定义属性.

Just to be clear I don't want to create user with custom attribute, but a custom attribute for all users in b2c.

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

Can I do it and if yes how?

推荐答案

你可以使用 创建 extensionProperty 为整个 b2c 实例创建用户自定义属性".

You can use Create extensionProperty to create a 'user custom attribute' for whole b2c instance.

请注意,我们需要将 targetObjects 指定为用户".

Please note we need to specify the targetObjects as "User".

一个例子:

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 的 Azure AD 应用程序的扩展属性,不带-"}_customAttribute.

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

Then you can update the extension property for any of your B2C account:

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 -> 下找到它.应用注册 ->所有应用程序.

The user custom attribute you created on Azure Portal is associated with the Azure AD app named b2c-extensions-app. Do not modify. Used by AADB2C for storing user data. You can find it under Azure AD B2C -> App registrations -> All applications.

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

But the custom attribute you created using Microsoft Graph won't appear on Azure Portal | User attributes no matter whether you create the custom attribute under b2c-extensions-app or any other Azure AD app.

这篇关于通过图形 api 或图形 sdk 为整个 B2C 实例创建用户自定义属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆