【问题标题】:How to include directory extension into access token in azure AD?如何在 Azure AD 中将目录扩展名包含到访问令牌中?
【发布时间】:2022-11-30 15:46:25
【问题描述】:

我已经创建了目录扩展并为其分配了数据,但是当我将它添加到令牌配置中时,它仍然不包含在访问令牌中,那么如何在 Azure AD 中包含目录扩展?

【问题讨论】:

    标签: azure azure-active-directory


    【解决方案1】:

    我试图在我的环境中重现相同的内容以在 azure AD 中添加自定义扩展属性。

    像下面这样创建一个新的应用程序注册

    Azure AD 门户>Azure Active Directory>应用程序注册

    (https://i.imgur.com/QwylSSx.png)

    使用 Graph Explorer 创建自定义扩展属性,并使用全局管理员帐户登录图形资源管理器。

    您可以获得如下所示的应用程序对象 ID

    Azure 门户>Azure Active Directory>应用程序注册>选择您的应用程序

    (https://i.imgur.com/lfTa8m7.png)

    在 graph explorer 中执行代码,如下所示

     GET https://graph.microsoft.com/v1.0/applications/<AppregistrationObjectID>
    

    修改代码以创建自定义扩展

    POST https://graph.microsoft.com/v1.0/applications/<AppregistrationObjectID>/extensionProperties
       {
    "name": "CustomAttribute",
    "dataType": "string",
    "targetObjects": [
    "User",
    "Group"
    ]
    }
    

    (https://i.imgur.com/dYVpC8M.png)

    将自定义属性添加到用户对象,如下所示

     PATCH https://graph.microsoft.com/v1.0/users/<UserObjectID>
        {
        "extension_47c8caba8d924ac9a0f159b0dcc8d4c7_CustomAttribute": "Demo"
        }
    

    (https://i.imgur.com/kmKPcmg.png)

    您可以获得如下所示的用户对象 ID

    Azure 门户>Azure Active Directory>用户>选择您的全局管理员用户

    (https://i.imgur.com/moB3C2D.png)

    在访问令牌中添加自定义属性

    (https://i.imgur.com/5BDo5FJ.png)

    最后添加了如下自定义扩展属性

    (https://i.imgur.com/ILmyiTd.png)

    【讨论】:

      猜你喜欢
      • 2020-12-25
      • 2021-05-26
      • 1970-01-01
      • 2020-12-21
      • 2019-12-31
      • 1970-01-01
      • 1970-01-01
      • 2020-07-05
      • 1970-01-01
      相关资源
      最近更新 更多