【问题标题】:Azure MS Graph Claim Mapping Policy PowershellAzure MS Graph 声明映射策略 Powershell
【发布时间】:2022-11-02 18:43:48
【问题描述】:

我对与声明映射策略相关的 MS Graph 文章[Vague] 有点困惑。我正在尝试使用 PowerShell 创建声明。使用以下格式创建新的索赔地图得到错误New-MgPolicyClaimMappingPolicy :属性定义具有无效值。

这里需要帮助!!!

    $policymap=[ordered]@{
definition=@(
@"
{
    "claimsMappingPolicy" :
        {
            "claimsSchema":[
                {
                    "source":"user"
                    "id":"assignedrikes"
                    "samlclaimtype":"https://aws.amazon.com/SAML/Attributes/Role"
                },
                {
                    "source":"user"
                    "id":"assignedrikes"
                    "samlclaimtype":"https://aws.amazon.com/SAML/Attributes/RoleSessionName"
                }
            ]
        }
    }
"@
)
displayname="Test"
isorganizationdefault=$false
}

New-MgPolicyClaimMappingPolicy -BodyParameter $policymap

【问题讨论】:

    标签: azure powershell azure-active-directory microsoft-graph-api


    【解决方案1】:

    新的索赔地图出现错误新的 MgPolicyClaimMappingPolicy

    如果您使用的格式不正确,可能会出现此错误samlclaimtype而不是使用MgPolicyClaimMappingPolicy,确保安装 Azure AD 预览版在脚本下面运行时。

    请检查以下几种解决方法:

    已安装 Azure AD 预览模块并使用以下脚本创建声明。

    Connect-AzureAD
    New-AzureADPolicy -Definition @('
    {
        "ClaimsMappingPolicy":
        {
            "Version":1,"IncludeBasicClaimSet":"true", 
            "ClaimsSchema": [{"Source":"user","ID":"extensionattribute1","SamlClaimType":"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/vikram","JwtClaimType":"vikram"}]
        }
    }') -DisplayName "vikram" -Type "ClaimsMappingPolicy"
    

    结果:

    尝试添加服务主体并检查是否成功。

    对于服务主体 ID,转到 Azure 门户 -> 企业应用程序 -> 您的 Web API -> 对象 ID如下所示:

    Add-AzureADServicePrincipalPolicy -Id <ObjectId of the Web API ServicePrincipal> -RefObjectId <ObjectId of the Policy>
    
    Get-AzureADServicePrincipalPolicy -Id <ObjectId of the Web API ServicePrincipal>
    

    要为该声明分配价值,请使用您的帐号登录 Microsoft Graph Explorer租户管理员帐户并在脚本下面运行。 ***这成功地完成了您的索赔映射的开发。 ***

    PATCH https://graph.microsoft.com/beta/me
    
    {
    "onPremisesExtensionAttributes": 
        {
            "extensionAttribute1": "vedha"
        }
    }
    

    现在转到 Azure 门户 -> Azure Active Directory -> 应用注册 -> 您的应用 -> 清单使您的主张接受为真的如下所示:

    然后,前往公开一个 API在下面管理编辑你的应用程序 ID URI图案像https://&lt;yourTenantDomain&gt;而不是默认的api://&lt;GUID&gt;,然后保存。

    生成访问令牌,您可以在解码的令牌中看到您创建的自定义声明。要解码令牌,您可以使用jwt.ms网站

    【讨论】:

      【解决方案2】:

      如果它对任何人有帮助,我还在这里添加了一些示例代码

      https://www.iam-specialist.com/msgraph-sdk-powershell/policies/create-claim-mapping

      【讨论】:

      • 虽然这在理论上可以回答这个问题,it would be preferable 在此处包含答案的基本部分,并提供链接以供参考。请edit回答所有相关信息。此外,在链接到您自己的内容时,请阅读how not to be a spammer
      猜你喜欢
      • 2018-12-19
      • 2018-12-07
      • 2023-02-17
      • 2019-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多