如何将Azure广告登录的属性映射到B2C身份?

如何将Azure广告登录的属性映射到B2C身份?,azure,azure-active-directory,claims-based-identity,azure-ad-b2c,identity-experience-framework,Azure,Azure Active Directory,Claims Based Identity,Azure Ad B2c,Identity Experience Framework,在这个示例之后,我们成功地将Azure AD目录('AD')与Azure AD B2C目录('B2C')联合起来,这样我们就可以对公共应用程序进行社交和自断言注册,我们的工作用户也可以使用他们的正常工作ID登录该应用程序。这很好,为我们解决了一个复杂的场景 在B2C保护的应用程序中,我们需要向广告用户显示与其工作身份相关的内容(特别是我们需要根据他们的工作角色筛选产品),但我们无法获得此信息,因为注册应用程序的过程会为用户生成新的B2C身份(实际上是他们广告身份的代理) 我们需要做的是将用户的原

在这个示例之后,我们成功地将Azure AD目录('AD')与Azure AD B2C目录('B2C')联合起来,这样我们就可以对公共应用程序进行社交和自断言注册,我们的工作用户也可以使用他们的正常工作ID登录该应用程序。这很好,为我们解决了一个复杂的场景

在B2C保护的应用程序中,我们需要向广告用户显示与其工作身份相关的内容(特别是我们需要根据他们的工作角色筛选产品),但我们无法获得此信息,因为注册应用程序的过程会为用户生成新的B2C身份(实际上是他们广告身份的代理)

我们需要做的是将用户的原始广告标识映射到新的B2C标识上。广告用户的其他属性(如给定姓名和姓氏)已经映射,这似乎发生在这里,通过
PartnerClaimType
属性,在自定义策略的
ClaimsProvider
元素中:

<OutputClaims>
    <OutputClaim ClaimTypeReferenceId="socialIdpUserId" PartnerClaimType="oid"/>
    <OutputClaim ClaimTypeReferenceId="tenantId" PartnerClaimType="tid"/>
    <OutputClaim ClaimTypeReferenceId="givenName" PartnerClaimType="given_name" />
    <OutputClaim ClaimTypeReferenceId="surName" PartnerClaimType="family_name" />
    <OutputClaim ClaimTypeReferenceId="displayName" PartnerClaimType="name" />
    <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="contosoAuthentication" />
    <OutputClaim ClaimTypeReferenceId="identityProvider" DefaultValue="AzureADContoso" />
</OutputClaims>

事实上,我们正在寻找的ID似乎可能映射到一个属性(
oid
)——但是当我们稍后为用户查询B2C图时,这个
oid
属性没有返回

那么-我们如何将用户的
对象ID
从工作广告目录映射到创建的新B2C标识上的属性上呢?

创建于11月28日17日

当前,Azure AD用户(或任何外部用户)的对象标识符保存到Azure AD B2C目录中的“alternativeSecurityId”属性中,但无法通过Azure AD Graph API查询此内置属性

但是,您可以创建自定义属性并将Azure AD identity provider中的“oid”声明映射到与此自定义属性关联的自定义声明

有关创建自定义属性并将其用作自定义声明的说明,请参见

对于您的特定场景,您应该:

1:将声明自定义索赔的
添加到基本保单:

<ClaimType Id="extension_AzureADUserObjectId">
  <DisplayName>Azure AD User Object ID</DisplayName>
  <DataType>string</DataType>
</ClaimType>
创建于17年11月28日

当前,Azure AD用户(或任何外部用户)的对象标识符保存到Azure AD B2C目录中的“alternativeSecurityId”属性中,但无法通过Azure AD Graph API查询此内置属性

但是,您可以创建自定义属性并将Azure AD identity provider中的“oid”声明映射到与此自定义属性关联的自定义声明

有关创建自定义属性并将其用作自定义声明的说明,请参见

对于您的特定场景,您应该:

1:将声明自定义索赔的
添加到基本保单:

<ClaimType Id="extension_AzureADUserObjectId">
  <DisplayName>Azure AD User Object ID</DisplayName>
  <DataType>string</DataType>
</ClaimType>

感谢您的详细回复。1,3,4非常清晰。#2-是否应将其添加到基础Azure AD技术配置文件中(TrustFrameworkBase中的“AAD-Common”)或者到TrustFrameworkExtensions中的“SignInWithContoso”技术配置文件?我已经尝试了这两种方法。前者的结果是没有向依赖方提出任何索赔;后者的结果是登录失败,消息为“server_error”Hi@JcFx。我编辑了上述答案。这是“SignInWithContoso”您必须向其添加输出声明映射的TP。服务器错误可能是由“AAD Common”引起的TP缺少扩展应用程序的元数据项,我已将其作为第3步插入。是的,我错过了第3步。有了这一步,它将按预期工作。非常感谢。感谢您的详细响应。1,3,4非常清晰。#2-是否应将其添加到基础Azure AD技术配置文件中(“AAD-Common”在TrustFrameworkBase中)或者到TrustFrameworkExtensions中的“SignInWithContoso”技术配置文件?我已经尝试了这两种方法。前者的结果是没有向依赖方提出任何索赔;后者的结果是登录失败,消息为“server_error”Hi@JcFx。我编辑了上述答案。这是“SignInWithContoso”您必须向其添加输出声明映射的TP。服务器错误可能是由于“AAD Common”TP缺少扩展应用程序的元数据项造成的,我已在上面的步骤3中插入了这些元数据项。是的,我错过了步骤3。有了这些,它将按预期工作。非常感谢。
<TechnicalProfile Id="AAD-Common">
  <DisplayName>Azure Active Directory</DisplayName>
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.AzureActiveDirectoryProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
  <Metadata>
    <Item Key="ApplicationObjectId">Insert the object identifier for the b2c-extensions-app application here</Item>
    <Item Key="ClientId">Insert the application identifier for the b2c-extensions-app application here</Item>
  </Metadata>
  <CryptographicKeys>
    <Key Id="issuer_secret" StorageReferenceId="TokenSigningKeyContainer" />
  </CryptographicKeys>
  ...
</TechnicalProfile>
<PersistedClaims>
  ...
  <PersistedClaim ClaimTypeReferenceId="extension_AzureADUserObjectId" />
</PersistedClaims>
<OutputClaims>
  ...
  <OutputClaim ClaimTypeReferenceId="extension_AzureADUserObjectId" />
</OutputClaims>
{
    "userIdentities": [
        {
            "issuer": "contoso.com",
            "issuerUserId": "Mjk2NzdlNTAtY2MwZS00MmU5LWJhNWMtZjFmMDdkZTUwMDhm"
        }
    ]
}