azure-ad-b2c - 将 DefaultValue 设置为 DateTime.Now() 等效项

标签 azure-ad-b2c identity-experience-framework

如何将默认值设置为当前日期和时间?

<OutputClaims>
    <OutputClaim ClaimTypeReferenceId="extension_MyCustomClaim" DefaultValue="DateTime.Now()">
</OutputClaims>

ClaimType 供引用:

<ClaimType Id="extension_MyCustomClaim">
    <DisplayName>Some Date/Time</DisplayName>
    <DataType>date</DataType>
    <DefaultPartnerClaimTypes>
      <Protocol Name="OAuth2" PartnerClaimType="myCustomClaim" />
      <Protocol Name="OpenIdConnect" PartnerClaimType="myCustomClaim" />
    </DefaultPartnerClaimTypes>
    <AdminHelpText>Some date time</AdminHelpText>
    <UserInputType>TextBox</UserInputType>
</ClaimType>

更新

Unable to upload policy. Reason : Validation failed: 1 validation error(s) found in policy "B2C_1A_TRUSTFRAMEWORK_BUILDINGBLOCKS" of tenant "my-tenant.onmicrosoft.com".The OutputClaims mismatched in ClaimsTransformation with id "GetSystemDateTime" with TransformationMethod "GetCurrentDateTime".

The following OutputClaims were declared in the Policy but were not expected by the TransformMethod: [Date]currentDateTime. The following OutputClaims were expected by the TransformMethod but were not declared in the Policy: [DateTime]currentDateTime.

想知道我是否需要更新的 base.xml 文件?想法? 💭

最佳答案

您可以声明 GetCurrentDateTime 类型的声明转换,然后从技术配置文件中调用它作为输出声明转换:

  <ClaimsTransformation Id="GetNow" TransformationMethod="GetCurrentDateTime">
    <OutputClaims>
      <OutputClaim ClaimTypeReferenceId="extension_MyCustomClaim" TransformationClaimType="currentDateTime" />
    </OutputClaims>
  </ClaimsTransformation>

此外,ClaimTypeDataType 必须是 dateTime

<ClaimType Id="extension_MyCustomClaim">
    ...
    <DataType>dateTime</DataType>
    ...
</ClaimType>

关于azure-ad-b2c - 将 DefaultValue 设置为 DateTime.Now() 等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51025766/

相关文章:

azure-ad-b2c - 没有电子邮件验证步骤的 Azure AD B2C 密码重置策略

azure-ad-b2c - 自定义策略验证错误

azure-ad-b2c - 如何为 Azure AD B2C 设置用户旅程查看器

azure - 如何将属性从 Azure AD 登录映射到 B2C 身份?

Azure AD B2C : The redirect URI in the request, 与 OAuth 客户端授权的不匹配

ios - 如何在 iOS 应用程序中实现 Azure AD B2C PasswordReset 功能

azure - Azure AD B2C 中对 React React Native 应用程序的授权

azure - 电子邮件声明未使用 Azure B2C 中的自定义策略填充

azure - 刷新访问 token 时调用自定义 REST API

azure-ad-b2c - 在登录期间接受用户名或电子邮件