Azure B2C:在哪里创建要在自定义策略中使用的DateTime扩展属性-门户或自定义策略或两者兼有



我需要在数据类型为"的自定义策略中使用一个扩展属性;DateTime";。我将索赔类型定义如下。

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

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

Q1.这样申报就足够了吗?Q2.我是否也需要在门户中的"用户属性"下创建它?我不确定,因为在门户中只有int、boolean和string数据类型可用。我可以用其中任何一个来代替dateTime吗?

编辑以下是使用属性的转换

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

谢谢你的帮助!

您在自定义策略中定义的是就足够了。您是对的,您不能在Portal中创建dateTime类型的自定义属性。

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

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

您需要像从技术配置文件进行输入或输出索赔转换一样调用索赔转换。以及用户旅程中的技术简介参考。然后它将被输出并发布到令牌中。

非常感谢你们的努力。在我的场景中,我需要在登录期间更新我的扩展属性,而不是像建议的示例中那样在注册期间更新。为了解决此问题,我在Azure AD声明提供程序中添加了一个额外的AAD-XXX技术配置文件,该配置文件可以执行"写入"操作,但RaiseErrorIfClaimsPrincipalAlreadyExists=>'false。这使我能够在InputClaimsTransformation元素中调用我的声明转换,然后使用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>

最新更新