azure - 将自定义声明 "samaccountname"添加到 Azure 广告中时出现问题

标签 azure authentication jwt claims-based-identity

我需要添加自定义声明“samAccountName”以显示在 token 中(使用 jwt)

首先,我创建了 powershell 脚本

New-AzureADPolicy -Definition @('{
                     "ClaimsMappingPolicy": {
                         "Version": 1,
                         "IncludeBasicClaimSet": "true",
                         "ClaimsSchema":[{

                                 "Source": "user",
                                 "ID": "onpremisessamaccountname",
                                 "SamlClaimType": "samaccountname",
                                 "JwtClaimType": "samAccountName"
                             },
  ]
                     }
                 }') -DisplayName "att_ext_samaccountname_even2_prod" -Type "ClaimsMappingPolicy"

我将新策略设置为我的 objectid,看起来没问题 enter image description here

在 azure list 中,我输入了“acceptMappedClaims”:true,它看起来像这样

enter image description here

但在“ token 配置 -> 可选声明”中,它看起来像这样(警告标志)

enter image description here

当选择“添加可选声明”时,我找不到要添加的声明

对我做错了什么或者缺少什么有什么想法吗?

提前致谢

最佳答案

我尝试在我的环境中重现相同的结果并得到以下结果:

我将 acceptedMappedClaims 修改为 true 并在应用 list 中添加了扩展程序,如下所示:

enter image description here

并得到与以下相同的错误:

enter image description here

或者,我使用下面的 PowerShell 命令在 token 中添加 samaccountname 扩展,如下所示:

$MyApp = (New-AzureADApplication -DisplayName "AppName").ObjectId  

New-AzureADServicePrincipal -AppId (Get-AzureADApplication -SearchString "AppName").AppId  

New-AzureADApplicationExtensionProperty -ObjectId $MyApp -Name "samaccountname" -DataType "String" -TargetObjects "User"  

Set-AzureADUserExtension -ObjectId ServicePrincipalObjectId -ExtensionName "extension_XXXX_samaccountname" -ExtensionValue "Value"

执行上述命令后,我得到如下响应:

enter image description here

我能够将 samaccountname 添加为 Azure 门户中的可选声明,如下所示:

enter image description here

解码 token (使用授权代码生成)后,流程成功获得samaccountname,如下所示:

enter image description here

欲了解更多详情,请引用以下链接:

Azure AD cmdlets to work with extension attributes | Microsoft Docs

Inlcude onpemise samaccount in azure ad claims by soumi-MSFT

关于azure - 将自定义声明 "samaccountname"添加到 Azure 广告中时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72980955/

相关文章:

authentication - 推送包时如何避免nuget认证?

GOLANG 从内存加载 JWK(JSON Web key )而不是从 URL 加载?拿来

c# - azure 表存储插入操作中出现错误请求错误

javascript - "InvalidImageSize", "message": "Image size is too small."

c# - 带有 Azure Functions 的 DocumentDB

Azure API 管理策略 : test if param in request body exist

python - 登录对话框 PyQt

session 类上的 java.lang.NullPointerException

javascript - 获取用户,但不使用 Express Passport + JWT 中间件返回 401

jwt - 我可以使用 jwt 来存储用户的购物车商品直到结账吗?