【问题标题】:Azure B2C: Where to Create DateTime Extension Attribute to be used in Custom Policy- Portal or Custom Policy or Both?Azure B2C:在哪里创建要在自定义策略门户或自定义策略或两者中使用的日期时间扩展属性?
【发布时间】:2020-07-30 08:56:48
【问题描述】:

我需要在数据类型“DateTime”的自定义策略中使用扩展属性。我将声明类型定义如下。

<ClaimType Id="extension_myAttribute">
        <DisplayName>myAttrbute</DisplayName>
        <DataType>dateTime</DataType>
        <UserHelpText>This is for X</UserHelpText>
      </ClaimType>

我希望能够将此属性与当前时间进行比较,从而指导用户旅程。但是,当我查看应用程序见解时,该值是“未定义的”,因此将其与包含当前时间的声明类型进行比较对我没有好处。即使我将属性添加到依赖方文件中的 OutputClaims 中,该属性也作为声明丢失。

第一季度。以这种方式声明就足够了吗? Q2。我是否也需要在门户的用户属性下创建它?我不确定,因为在门户中只有数据类型 int、boolean 和 string 可用。我可以使用其中任何一个来代替 dateTime 吗?

编辑 这是使用属性的转换

  <ClaimsTransformation Id="SetMyAttribute" TransformationMethod="GetCurrentDateTime">
    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="extension_MyAttribute" TransformationClaimType="currentDateTime" />
    </OutputClaims>
  </ClaimsTransformation>

感谢您的帮助!

【问题讨论】:

    标签: xml azure azure-active-directory azure-ad-b2c azure-ad-graph-api


    【解决方案1】:

    是的,正如您在自定义策略中定义的那样,这就足够了。没错,您不能在 Portal 中创建 dateTime 类型的自定义属性。

    请参考此链接:https://github.com/azure-ad-b2c/samples/tree/master/policies/force-password-reset-after-90-days

    这是在 90 天后进行密码重置。这肯定与您要实施的内容有关。

    【讨论】:

    • 谢谢@Rohit。我看了看,就声明类型及其用途而言,我似乎完全按照作者所做的那样做。看来我需要提供更多信息。我会在几分钟后添加一个编辑。
    【解决方案2】:

    您需要将您的声明转换称为技术配置文件的输入或输出声明转换。以及来自您的用户旅程的技术资料的参考。然后将其输出并发放到令牌中。

    【讨论】:

    • 谢谢贾斯。正如@Rohit 建议的那样,我查看了示例。在示例中,AAD-UserWriteUsingLogonEmail 和 AAD-UserWritePasswordUsingObjectId 技术配置文件用于调用使用当前时间填充 extension_passwordResetOn 属性的 SetPasswordResetOn 声明转换。然后,TP 将属性保留在 AAD 中。问题是在注册期间和密码重置期间填充了 extension_passwordResetOn,但我希望能够在用户登录期间填充我的扩展属性。如何在用户登录后将属性写入 AAD?
    【解决方案3】:

    真的很感谢你们俩的尝试。在我的场景中,我需要在登录期间更新我的扩展属性,而不是在建议的示例中进行注册。为了解决这个问题,我在 Azure AD 声明提供程序中添加了一个额外的 AAD-XXX 技术配置文件,该配置文件可以执行“写入”操作,但 RaiseErrorIfClaimsPrincipalAlreadyExists => 'false'。这使我能够在 InputClaimtsTransformation 元素中调用我的声明转换,然后使用 PersistedClaims 元素写入 AAD。像下面的东西。我希望这对其他人有帮助。

    <TechnicalProfile Id="AAD-XXXX">
      <Metadata>
        <Item Key="Operation">Write</Item>
        <Item Key="RaiseErrorIfClaimsPrincipalAlreadyExists">false</Item>
      </Metadata>
      <InputClaimsTransformations>
        <!--call claims transformation-->
        <InputClaimsTransformation ReferenceId="MyClaimsTransformation" />
      </InputClaimsTransformations>
      <InputClaims>
        <InputClaim ClaimTypeReferenceId="objectId" />
      </InputClaims>
      <PersistedClaims>
        <!-- Required claims -->
        <PersistedClaim ClaimTypeReferenceId="objectId" />
        <PersistedClaim ClaimTypeReferenceId="userPrincipalName" />
        <PersistedClaim ClaimTypeReferenceId="displayName" />
        <PersistedClaim ClaimTypeReferenceId="extension_MyExtensionAttribute" />
      </PersistedClaims>
      <IncludeTechnicalProfile ReferenceId="AAD-Common" />
      <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" /> 
    </TechnicalProfile>
    

    【讨论】:

    • 感谢您的回答。但由于某种原因,我的 TechnicalProfile 似乎没有执行。在我的 我尝试通过以下方式包含它:` `
    • 我在用户旅程中回答了我自己的问题我添加了一个编排步骤:&lt;OrchestrationStep Order="4" Type="ClaimsExchange"&gt; &lt;ClaimsExchanges&gt; &lt;ClaimsExchange Id="AAD-UserWriteLoginTimestampUsingObjectId" TechnicalProfileReferenceId="AAD-UserWriteLoginTimestampUsingObjectId"/&gt; &lt;/ClaimsExchanges&gt; &lt;/OrchestrationStep&gt;
    猜你喜欢
    • 2019-04-13
    • 1970-01-01
    • 1970-01-01
    • 2021-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多