重要
2025 年 5 月 1 日より、Azure AD B2C は新規のお客様向けに購入できなくなります。 詳細については、FAQ を参照してください。
この記事では、Azure Active Directory B2C (Azure AD B2C) で Identity Experience Framework スキーマの日付要求変換を使用する例を示します。 詳細については、「要求変換」をご覧ください。
AssertDateTimeIsGreaterThan (日付時間が大きい)
1 つの日付が 2 番目の日付より後であることをアサートします。
rightOperand
がleftOperand
より大きいかどうかを判断します。 "はい" の場合は、例外をスローします。 この要求変換のライブ デモをご覧ください。
要素 | トランスフォーメーションクレームタイプ | データ型 | 注記 |
---|---|---|---|
インプットクレーム | leftOperand (左オペランド) | ひも | 最初の要求の種類。2 番目の要求より後にする必要があります。 |
インプットクレーム | rightオペランド | ひも | 2 番目の要求の種類。最初の要求より前である必要があります。 |
入力パラメータ | AssertIfEqualTo (アサート・イフ・イコール・トゥ) | ブーリアン | 左オペランドが右オペランドと等しい場合に、このアサーションでエラーをスローするかどうかを指定します。 指定できる値は true (既定値) またはfalse です。 |
入力パラメータ | AssertIfRightOperandIsNotPresent | ブーリアン | 右オペランドが見つからない場合に、このアサーションを渡す必要があるかどうかを指定します。 |
入力パラメータ | TreatAsEqualIfWithinMillseconds (ミリ秒以内に等しい場合) | 整数 (int) | 2 つの日付時刻の間で時間が等しいと見なすミリ秒数を指定します (たとえば、クロック スキューを考慮します)。 |
AssertDateTimeIsGreaterThan 要求変換は、セルフアサート技術プロファイルによって呼び出される検証技術プロファイルから常に実行されます。 DateTimeGreaterThan セルフアサート技術プロファイル メタデータは、技術プロファイルがユーザーに提示するエラー メッセージを制御します。 エラー メッセージは、ローカライズできます。
AssertDateTimeIsGreaterThan の例
次の例では、 currentDateTime
要求と approvedDateTime
要求を比較します。
currentDateTime
がapprovedDateTime
より後の場合、エラーがスローされます。 変換では、値が 5 分以内 (3,0000 ミリ秒) の差である場合、値は等しいと見なされます。
AssertIfEqualTo
が false
に設定されているため、値が等しい場合、エラーはスローされません。
<ClaimsTransformation Id="AssertApprovedDateTimeLaterThanCurrentDateTime" TransformationMethod="AssertDateTimeIsGreaterThan">
<InputClaims>
<InputClaim ClaimTypeReferenceId="approvedDateTime" TransformationClaimType="leftOperand" />
<InputClaim ClaimTypeReferenceId="currentDateTime" TransformationClaimType="rightOperand" />
</InputClaims>
<InputParameters>
<InputParameter Id="AssertIfEqualTo" DataType="boolean" Value="false" />
<InputParameter Id="AssertIfRightOperandIsNotPresent" DataType="boolean" Value="true" />
<InputParameter Id="TreatAsEqualIfWithinMillseconds" DataType="int" Value="300000" />
</InputParameters>
</ClaimsTransformation>
注
上記の例では、 AssertIfEqualTo
入力パラメーターを削除し、 currentDateTime
が等しい場合approvedDateTime
、エラーがスローされます。
AssertIfEqualTo
の既定値はtrue
です。
- 入力要求:
- 左オペランド: 2022-01-01T15:00:00
- rightオペランド: 2022-01-22T15:00:00
- 入力パラメーター:
- AssertIfEqualTo: 偽
- AssertIfRightOperandIsNotPresent: 真
- TreatAsEqualIfWithinMillseconds: 300000 (30 秒)
- 結果:エラーがスローされます
要求変換を呼び出す
次の Example-AssertDates
検証技術プロファイルは、 AssertApprovedDateTimeLaterThanCurrentDateTime
要求変換を呼び出します。
<TechnicalProfile Id="Example-AssertDates">
<DisplayName>Unit test</DisplayName>
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.ClaimsTransformationProtocolProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="ComparisonResult" DefaultValue="false" />
</OutputClaims>
<OutputClaimsTransformations>
<OutputClaimsTransformation ReferenceId="AssertDates" />
</OutputClaimsTransformations>
<UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
</TechnicalProfile>
セルフアサート技術プロファイルは、検証 Example-AssertDates
技術プロファイルを呼び出します。
<TechnicalProfile Id="SelfAsserted-AssertDateTimeIsGreaterThan">
<DisplayName>User ID signup</DisplayName>
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Metadata>
<Item Key="ContentDefinitionReferenceId">api.selfasserted</Item>
<Item Key="DateTimeGreaterThan">Custom error message if the provided right operand is greater than the right operand.</Item>
</Metadata>
...
<ValidationTechnicalProfiles>
<ValidationTechnicalProfile ReferenceId="ClaimsTransformation-AssertDateTimeIsGreaterThan" />
</ValidationTechnicalProfiles>
</TechnicalProfile>
ConvertDateTimeToDateClaim (日付要求に変換)
DateTime
要求の種類をDate
要求の種類に変換します。 要求変換では、日付から時刻形式が削除されます。 この要求変換のライブ デモをご覧ください。
要素 | トランスフォーメーションクレームタイプ | データ型 | 注記 |
---|---|---|---|
インプットクレーム | 入力クレーム | 日時 | 変換する要求の種類。 |
出力要求 | 出力クレーム | 日付 | この要求変換が呼び出された後に生成される要求の種類。 |
ConvertDateTimeToDateClaim の例
次の例では、要求 systemDateTime
(dateTime データ型) から別の要求 systemDate
(日付データ型) への変換を示します。
<ClaimsTransformation Id="ConvertToDate" TransformationMethod="ConvertDateTimeToDateClaim">
<InputClaims>
<InputClaim ClaimTypeReferenceId="systemDateTime" TransformationClaimType="inputClaim" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="systemDate" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
- 入力要求:
- 入力クレーム: 2022-01-03T11:34:22.0000000Z
- 出力要求:
- outputClaim: 2022-01-03
ConvertDateToDateTimeClaim (日付から日付への請求への変換)
Date
要求の種類をDateTime
要求の種類に変換します。 要求変換では、時刻形式が変換され、午前 12 時 00 分 00 分が日付に追加されます。 この要求変換のライブ デモをご覧ください。
要素 | トランスフォーメーションクレームタイプ | データ型 | 注記 |
---|---|---|---|
インプットクレーム | 入力クレーム | 日付 | 変換する要求の種類。 |
出力要求 | 出力クレーム | 日時 | この要求変換が呼び出された後に生成される要求の種類。 |
ConvertDateToDateTimeClaim の例
次の例では、要求 dateOfBirth
(日付データ型) から別の要求 dateOfBirthWithTime
(dateTime データ型) への変換を示します。
<ClaimsTransformation Id="ConvertToDateTime" TransformationMethod="ConvertDateToDateTimeClaim">
<InputClaims>
<InputClaim ClaimTypeReferenceId="dateOfBirth" TransformationClaimType="inputClaim" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="dateOfBirthWithTime" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
- 入力要求:
- 入力クレーム: 2022-01-03
- 出力要求:
- 出力クレーム: 2022-01-03T00:00:00.000000Z
日時の比較
2 つの日付を比較し、最初の日付が後、前、または別の日付と等しいかどうかを判断します。 結果は、値が true
または false
の新しいブール型要求になります。 この要求変換のライブ デモをご覧ください。
要素 | トランスフォーメーションクレームタイプ | データ型 | 注記 |
---|---|---|---|
インプットクレーム | firstDateTime(ファーストデートタイム) | 日時 | 2 番目の日付の後、前、または等しいかどうかを比較する最初の日付。 Null 値の場合は例外がスローされます。 |
インプットクレーム | セカンドデイトタイム | 日時 | 比較する 2 番目の日付。 Null 値は、現在の日付と時刻として扱われます。 |
入力パラメータ | timeSpanInSeconds (英語) | 整数 (int) | 最初の日付に追加する期間。 指定できる値は、負の -2,147,483,648 から正の 2,147,483,647 までの範囲です。 |
入力パラメータ | オペレーター | ひも | 次のいずれかの値: same 、 later than 、または earlier than 。 |
出力要求 | 結果 | ブーリアン | この要求変換が呼び出された後に生成される要求。 |
DateTimeComparison の例
この要求変換を使用して、最初の日付と timeSpanInSeconds
パラメーターが後、前、または別の日付と等しいかどうかを判断します。 次の例は、最初の日付 (2022-01-01T00:00:00) と 90 日が 2 番目の日付 (2022-03-16T00:00:00) より後であることを示しています。
<ClaimsTransformation Id="CompareLastTOSAcceptedWithCurrentDateTime" TransformationMethod="DateTimeComparison">
<InputClaims>
<InputClaim ClaimTypeReferenceId="extension_LastTOSAccepted" TransformationClaimType="secondDateTime" />
<InputClaim ClaimTypeReferenceId="currentDateTime" TransformationClaimType="firstDateTime" />
</InputClaims>
<InputParameters>
<InputParameter Id="operator" DataType="string" Value="later than" />
<InputParameter Id="timeSpanInSeconds" DataType="int" Value="7776000" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="isLastTOSAcceptedGreaterThanNow" TransformationClaimType="result" />
</OutputClaims>
</ClaimsTransformation>
- 入力要求:
- 初回日時: 2022-01-01T00:00:00.100000Z
- secondDateTime:2022-03-16T00:00:00.100000Z
- 入力パラメーター:
- 演算子: 次より後
- timeSpanInSeconds: 7776000 (90 日)
- 出力要求:
- 結果: true
IsTermsOfUseConsent必須
dateTime
要求の種類が特定の日付より前か大きいかを判断します。 結果は、値が true
または false
の新しいブール型要求になります。 この要求変換のライブ デモをご覧ください。
アイテム | トランスフォーメーションクレームタイプ | データの種類 | 注記 |
---|---|---|---|
インプットクレーム | termsOfUseConsentDateTime(利用規約利用規約) | 日時 |
dateTime 入力パラメーターより前かそれ以降かを確認するtermsOfUseTextUpdateDateTime 要求の種類。 未定義の値は結果 true 返します。 |
入力パラメータ | termsOfUseTextUpdateDateTime | 日時 |
dateTime 入力要求より前かそれ以降かを確認するtermsOfUseConsentDateTime 要求の種類。 日付の時刻部分は省略可能です。 |
出力要求 | 結果 | ブーリアン | この要求変換が呼び出された後に生成される要求の種類。 |
この要求変換を使用して、 dateTime
要求の種類が特定の日付より前か大きいかを判断します。 たとえば、ユーザーが最新バージョンの利用規約 (TOU) またはサービス条件に同意したかどうかを確認します。 ユーザーが最後に同意した時刻を確認するには、ユーザーが最後に TOU を受け入れた時刻を 拡張属性に格納します。 TOU の文言が変更されたら、 termsOfUseTextUpdateDateTime
入力パラメーターを変更時刻に更新します。 次に、この要求変換を呼び出して日付を比較します。 要求変換が true
を返す場合、 termsOfUseConsentDateTime
値は termsOfUseTextUpdateDateTime
値より前であり、更新された TOU を受け入れるようにユーザーに依頼できます。
<ClaimsTransformation Id="IsTermsOfUseConsentRequired" TransformationMethod="IsTermsOfUseConsentRequired">
<InputClaims>
<InputClaim ClaimTypeReferenceId="extension_termsOfUseConsentDateTime" TransformationClaimType="termsOfUseConsentDateTime" />
</InputClaims>
<InputParameters>
<InputParameter Id="termsOfUseTextUpdateDateTime" DataType="dateTime" Value="2021-11-15T00:00:00" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="termsOfUseConsentRequired" TransformationClaimType="result" />
</OutputClaims>
</ClaimsTransformation>
IsTermsOfUseConsentRequired の例
- 入力要求:
- termsOfUseConsentDateTime: 2020-03-09T09:15:00
- 入力パラメーター:
- termsOfUseTextUpdateDateTime: 2021-11-15
- 出力要求:
- 結果: true
現在日時を取得する
現在の UTC 日時を取得し、値を要求の種類に追加します。 この要求変換のライブ デモをご覧ください。
要素 | トランスフォーメーションクレームタイプ | データ型 | 注記 |
---|---|---|---|
出力要求 | 現在の日付時刻 | 日時 | この要求変換が呼び出された後に生成される要求の種類。 |
GetCurrentDateTime の例
次の例は、現在のデータと時刻を取得する方法を示しています。
<ClaimsTransformation Id="GetSystemDateTime" TransformationMethod="GetCurrentDateTime">
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="systemDateTime" TransformationClaimType="currentDateTime" />
</OutputClaims>
</ClaimsTransformation>
- 出力要求:
- 現在の日時: 2022-01-14T11:40:35.0000000Z
次のステップ
- その他の要求変換のサンプルについては、Azure AD B2C コミュニティの GitHub リポジトリをご覧ください