重要
2025 年 5 月 1 日より、Azure AD B2C は新規のお客様向けに購入できなくなります。 詳細については、FAQ を参照してください。
この記事では、Azure Active Directory B2C (Azure AD B2C) で Identity Experience Framework スキーマのブール要求変換を使用する例を示します。 詳細については、「要求変換」をご覧ください。
アンドクレーム
2 つのブール入力要求の And
演算を計算し、操作の結果を使用して出力要求を設定します。 この要求変換のライブ デモをご覧ください。
要素 | トランスフォーメーションクレームタイプ | データ型 | 注記 |
---|---|---|---|
インプットクレーム | inputClaim1 | ブーリアン | 評価する最初の要求。 |
インプットクレーム | inputClaim2 | ブーリアン | 評価する 2 番目の要求。 |
出力要求 | 出力クレーム | ブーリアン | この要求変換が呼び出された後に生成される要求 (true または false)。 |
AndClaims の例
次の要求変換は、And
とisEmailNotExist
の 2 つのブール型要求をisSocialAccount
する方法を示しています。 出力要求presentEmailSelfAsserted
は、両方の入力要求の値がtrue
場合にtrue
に設定されます。
<ClaimsTransformation Id="CheckWhetherEmailBePresented" TransformationMethod="AndClaims">
<InputClaims>
<InputClaim ClaimTypeReferenceId="isEmailNotExist" TransformationClaimType="inputClaim1" />
<InputClaim ClaimTypeReferenceId="isSocialAccount" TransformationClaimType="inputClaim2" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="presentEmailSelfAsserted" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
- 入力要求:
- inputClaim1: 真
- inputClaim2: 偽の場合
- 出力要求:
- outputClaim: いいえ
AssertBooleanClaimIsEqualToValue
2 つの要求のブール値が等しいことを確認し、等しくない場合は例外をスローします。 この要求変換のライブ デモをご覧ください。
要素 | トランスフォーメーションクレームタイプ | データ型 | 注記 |
---|---|---|---|
入力クレーム | 入力クレーム | ブーリアン | 確認する要求。 |
入力パラメータ | valueToCompareTo (値の比較) | ブーリアン | 比較する値 (true または false)。 |
AssertBooleanClaimIsEqualToValue 要求変換は、セルフアサート技術プロファイルによって呼び出される検証技術プロファイルから常に実行されます。 UserMessageIfClaimsTransformationBooleanValueIsNotEqual セルフアサート技術プロファイル メタデータは、技術プロファイルがユーザーに提示するエラー メッセージを制御します。 エラー メッセージは、ローカライズできます。
AssertBooleanClaimIsEqualToValue の例
次の要求変換は、ブール型要求の値と true
値を確認する方法を示しています。
accountEnabled
要求の値が false の場合は、エラー メッセージがスローされます。
<ClaimsTransformation Id="AssertAccountEnabledIsTrue" TransformationMethod="AssertBooleanClaimIsEqualToValue">
<InputClaims>
<InputClaim ClaimTypeReferenceId="accountEnabled" TransformationClaimType="inputClaim" />
</InputClaims>
<InputParameters>
<InputParameter Id="valueToCompareTo" DataType="boolean" Value="true" />
</InputParameters>
</ClaimsTransformation>
- 入力要求:
- inputClaim: 偽の場合
- valueToCompareTo: 真
- 結果:エラーがスローされます
AssertBooleanClaimIsEqualToValue 要求変換の呼び出し
次の Example-AssertBoolean
検証技術プロファイルは、 AssertAccountEnabledIsTrue
要求変換を呼び出します。
<TechnicalProfile Id="Example-AssertBoolean">
<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="AssertAccountEnabledIsTrue" />
</OutputClaimsTransformations>
<UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
</TechnicalProfile>
セルフアサート技術プロファイルは、検証 Example-AssertBoolean
技術プロファイルを呼び出します。
<TechnicalProfile Id="SelfAsserted-AssertDateTimeIsGreaterThan">
<DisplayName>Example</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="UserMessageIfClaimsTransformationBooleanValueIsNotEqual">Custom error message if account is disabled.</Item>
</Metadata>
...
<ValidationTechnicalProfiles>
<ValidationTechnicalProfile ReferenceId="Example-AssertBoolean" />
</ValidationTechnicalProfiles>
</TechnicalProfile>
CompareBooleanClaimToValue
要求のブール値が true
または false
と等しいことを確認し、圧縮の結果を返します。 この要求変換のライブ デモをご覧ください。
要素 | トランスフォーメーションクレームタイプ | データ型 | 注記 |
---|---|---|---|
インプットクレーム | 入力クレーム | ブーリアン | 比較する要求。 |
入力パラメータ | valueToCompareTo (値の比較) | ブーリアン | 比較する値 (true または false)。 |
出力要求 | compareResult (比較結果) | ブーリアン | この要求変換が呼び出された後に生成される要求。 |
CompareBooleanClaimToValue の例
次の要求変換は、ブール型要求の値と true
値を確認する方法を示しています。
IsAgeOver21Years
要求の値がtrue
と等しい場合、要求変換はtrue
を返します。それ以外の場合はfalse
。
<ClaimsTransformation Id="AssertAccountEnabled" TransformationMethod="CompareBooleanClaimToValue">
<InputClaims>
<InputClaim ClaimTypeReferenceId="IsAgeOver21Years" TransformationClaimType="inputClaim" />
</InputClaims>
<InputParameters>
<InputParameter Id="valueToCompareTo" DataType="boolean" Value="true" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="accountEnabled" TransformationClaimType="compareResult"/>
</OutputClaims>
</ClaimsTransformation>
- 入力要求:
- inputClaim: 偽の場合
- 入力パラメーター:
- valueToCompareTo: 真
- 出力要求:
- compareResult: 偽
NotClaims(免責事項)
ブール入力要求の Not
操作を計算し、操作の結果を使用して出力要求を設定します。 この要求変換のライブ デモをご覧ください。
要素 | トランスフォーメーションクレームタイプ | データ型 | 注記 |
---|---|---|---|
インプットクレーム | 入力クレーム | ブーリアン | 操作される要求。 |
出力要求 | 出力クレーム | ブーリアン | この要求変換が呼び出された後に生成される要求 (true または false)。 |
NotClaims の例
次の要求変換は、要求に対して論理否定を実行する方法を示しています。
<ClaimsTransformation Id="CheckWhetherEmailBePresented" TransformationMethod="NotClaims">
<InputClaims>
<InputClaim ClaimTypeReferenceId="userExists" TransformationClaimType="inputClaim" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="userExists" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
- 入力要求:
- inputClaim: 偽の場合
- 出力要求:
- outputClaim: true です。
またはクレーム
2 つのブール値要求の Or
を計算し、操作の結果を使用して出力要求を設定します。 この要求変換のライブ デモをご覧ください。
要素 | トランスフォーメーションクレームタイプ | データ型 | 注記 |
---|---|---|---|
インプットクレーム | inputClaim1 | ブーリアン | 評価する最初の要求。 |
インプットクレーム | inputClaim2 | ブーリアン | 評価する 2 番目の要求。 |
出力要求 | 出力クレーム | ブーリアン | この要求変換が呼び出された後に生成される要求 (true または false)。 |
OrClaims の例
次の要求変換は、2 つのブール型要求を Or
する方法を示しています。
<ClaimsTransformation Id="CheckWhetherEmailBePresented" TransformationMethod="OrClaims">
<InputClaims>
<InputClaim ClaimTypeReferenceId="isLastTOSAcceptedNotExists" TransformationClaimType="inputClaim1" />
<InputClaim ClaimTypeReferenceId="isLastTOSAcceptedGreaterThanNow" TransformationClaimType="inputClaim2" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="presentTOSSelfAsserted" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
- 入力要求:
- inputClaim1: 真
- inputClaim2: 偽の場合
- 出力要求:
- outputClaim: true です。
次のステップ
- その他の要求変換のサンプルについては、Azure AD B2C コミュニティの GitHub リポジトリをご覧ください