文字列要求変換String claims transformations
注意
Azure Active Directory B2C で、カスタム ポリシーは、主に、複雑なシナリオに取り組む用途向けに設計されています。In Azure Active Directory B2C, custom policies are designed primarily to address complex scenarios. ほとんどのシナリオで、組み込みユーザー フローを使用することをお勧めします。For most scenarios, we recommend that you use built-in user flows.
この記事では、Azure Active Directory B2C (Azure AD B2C) の Identity Experience Framework スキーマの文字列要求変換の使用例を示します。This article provides examples for using the string claims transformations of the Identity Experience Framework schema in Azure Active Directory B2C (Azure AD B2C). 詳細については、「ClaimsTransformations」を参照してください。For more information, see ClaimsTransformations.
AssertStringClaimsAreEqualAssertStringClaimsAreEqual
2 つの要求を比較し、それらが指定された比較 inputClaim1、inputClaim2 および stringComparison によれば等しくない場合は、例外をスローします。Compare two claims, and throw an exception if they are not equal according to the specified comparison inputClaim1, inputClaim2 and stringComparison.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaim1inputClaim1 | stringstring | 比較する最初の要求の種類。First claim's type, which is to be compared. |
InputClaimInputClaim | inputClaim2inputClaim2 | stringstring | 比較する 2 番目の要求の種類。Second claim's type, which is to be compared. |
InputParameterInputParameter | stringComparisonstringComparison | stringstring | 文字列比較で、次のいずれかの値です。序数、OrdinalIgnoreCase。string comparison, one of the values: Ordinal, OrdinalIgnoreCase. |
AssertStringClaimsAreEqual 要求変換は常に、セルフアサート技術プロファイルによって呼び出される 検証技術プロファイル (つまり DisplayConrtol) から実行されます。The AssertStringClaimsAreEqual claims transformation is always executed from a validation technical profile that is called by a self-asserted technical profile, or a DisplayConrtol. ユーザーに表示されるエラー メッセージは、セルフアサート技術プロファイルの UserMessageIfClaimsTransformationStringsAreNotEqual
メタデータによって制御されます。The UserMessageIfClaimsTransformationStringsAreNotEqual
metadata of a self-asserted technical profile controls the error message that is presented to the user. エラー メッセージは、ローカライズできます。The error messages can be localized.
この要求変換を使用して、2 つの ClaimTypes が同じ値を持っていることを確認できます。You can use this claims transformation to make sure, two ClaimTypes have the same value. そうでない場合は、エラー メッセージがスローされます。If not, an error message is thrown. 次の例では、strongAuthenticationEmailAddress ClaimType が email ClaimType と等しいことを確認します。The following example checks that the strongAuthenticationEmailAddress ClaimType is equal to email ClaimType. そうでない場合は、エラー メッセージがスローされます。Otherwise an error message is thrown.
<ClaimsTransformation Id="AssertEmailAndStrongAuthenticationEmailAddressAreEqual" TransformationMethod="AssertStringClaimsAreEqual">
<InputClaims>
<InputClaim ClaimTypeReferenceId="strongAuthenticationEmailAddress" TransformationClaimType="inputClaim1" />
<InputClaim ClaimTypeReferenceId="email" TransformationClaimType="inputClaim2" />
</InputClaims>
<InputParameters>
<InputParameter Id="stringComparison" DataType="string" Value="ordinalIgnoreCase" />
</InputParameters>
</ClaimsTransformation>
login-NonInteractive 検証技術プロファイルは、AssertEmailAndStrongAuthenticationEmailAddressAreEqual 要求変換を呼び出します。The login-NonInteractive validation technical profile calls the AssertEmailAndStrongAuthenticationEmailAddressAreEqual claims transformation.
<TechnicalProfile Id="login-NonInteractive">
...
<OutputClaimsTransformations>
<OutputClaimsTransformation ReferenceId="AssertEmailAndStrongAuthenticationEmailAddressAreEqual" />
</OutputClaimsTransformations>
</TechnicalProfile>
セルフアサート技術プロファイルによって login-NonInteractive 検証技術プロファイルが呼び出されます。The self-asserted technical profile calls the validation login-NonInteractive technical profile.
<TechnicalProfile Id="SelfAsserted-LocalAccountSignin-Email">
<Metadata>
<Item Key="UserMessageIfClaimsTransformationStringsAreNotEqual">Custom error message the email addresses you provided are not the same.</Item>
</Metadata>
<ValidationTechnicalProfiles>
<ValidationTechnicalProfile ReferenceId="login-NonInteractive" />
</ValidationTechnicalProfiles>
</TechnicalProfile>
例Example
- 入力要求:Input claims:
- inputClaim1: someone@contoso.cominputClaim1: someone@contoso.com
- inputClaim2: someone@outlook.cominputClaim2: someone@outlook.com
- 入力パラメーター:Input parameters:
- stringComparison: ordinalIgnoreCasestringComparison: ordinalIgnoreCase
- 結果:エラーがスローされますResult: Error thrown
ChangeCaseChangeCase
指定された要求の大文字または小文字を演算子に従って変更します。Changes the case of the provided claim to lower or upper case depending on the operator.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaim1inputClaim1 | stringstring | 変更する ClaimType。The ClaimType to be changed. |
InputParameterInputParameter | toCasetoCase | stringstring | 次のいずれかの値を指定できます。LOWER または UPPER 。One of the following values: LOWER or UPPER . |
OutputClaimOutputClaim | outputClaimoutputClaim | stringstring | この要求変換が呼び出された後に生成される ClaimType。The ClaimType that is produced after this claims transformation has been invoked. |
この要求変換を使用して、任意の文字列 ClaimType を小文字または大文字に変更します。Use this claim transformation to change any string ClaimType to lower or upper case.
<ClaimsTransformation Id="ChangeToLower" TransformationMethod="ChangeCase">
<InputClaims>
<InputClaim ClaimTypeReferenceId="email" TransformationClaimType="inputClaim1" />
</InputClaims>
<InputParameters>
<InputParameter Id="toCase" DataType="string" Value="LOWER" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="email" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- email: SomeOne@contoso.comemail: SomeOne@contoso.com
- 入力パラメーター:Input parameters:
- toCase:LOWERtoCase: LOWER
- 出力要求:Output claims:
- email: someone@contoso.comemail: someone@contoso.com
CreateStringClaimCreateStringClaim
変換で指定された入力パラメーターから文字列要求を作成します。Creates a string claim from the provided input parameter in the transformation.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputParameterInputParameter | valuevalue | stringstring | 設定する文字列。The string to be set. この入力パラメーターは、文字列要求変換式をサポートします。This input parameter supports string claims transformation expressions. |
OutputClaimOutputClaim | createdClaimcreatedClaim | stringstring | この要求変換が呼び出された後に生成される ClaimType は、入力パラメーターに指定された値で呼び出されています。The ClaimType that is produced after this claims transformation has been invoked, with the value specified in the input parameter. |
この要求変換を使用して、文字列 ClaimType 値を設定します。Use this claims transformation to set a string ClaimType value.
<ClaimsTransformation Id="CreateTermsOfService" TransformationMethod="CreateStringClaim">
<InputParameters>
<InputParameter Id="value" DataType="string" Value="Contoso terms of service..." />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="TOS" TransformationClaimType="createdClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力パラメーター:Input parameter:
- value:Contoso terms of service...value: Contoso terms of service...
- 出力要求:Output claims:
- createdClaim:TOS ClaimType には「Contoso サービス利用規約...」の値が含まれています。createdClaim: The TOS ClaimType contains the "Contoso terms of service..." value.
CopyClaimIfPredicateMatchCopyClaimIfPredicateMatch
入力要求の値が出力要求の述語と一致する場合は、要求の値を別の値にコピーします。Copy value of a claim to another if the value of the input claim matches the output claim predicate.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaiminputClaim | stringstring | コピーする要求の種類。The claim type, which is to be copied. |
OutputClaimOutputClaim | outputClaimoutputClaim | stringstring | この要求変換が呼び出された後に生成される要求の種類。The claim type that is produced after this claims transformation has been invoked. 入力要求の値は、この要求の述語に対してチェックされます。The value of the input claim is checked against this claim predicate. |
次の例では、signInName が電話番号の場合にのみ、signInName 要求の値が phoneNumber 要求にコピーされます。The following example copies the signInName claim value to phoneNumber claim, only if the signInName is a phone number. 完全なサンプルについては、電話番号または電子メールによるサインインに関するスターター パック ポリシーを参照してください。For the complete sample, see Phone number or email sign-in starter pack policy.
<ClaimsTransformation Id="SetPhoneNumberIfPredicateMatch" TransformationMethod="CopyClaimIfPredicateMatch">
<InputClaims>
<InputClaim ClaimTypeReferenceId="signInName" TransformationClaimType="inputClaim" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="phoneNumber" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例 1Example 1
- 入力要求:Input claims:
- inputClaim: bob@contoso.cominputClaim: bob@contoso.com
- 出力要求:Output claims:
- outputclaim: 出力要求は元の値から変更されません。outputClaim: The output claim won't be changed from its original value.
例 2Example 2
- 入力要求:Input claims:
- inputClaim: +11234567890inputClaim: +11234567890
- 出力要求:Output claims:
- outputClaim: +11234567890outputClaim: +11234567890
CompareClaimsCompareClaims
文字列要求が相互に等しいかどうかを確認します。Determine whether one string claim is equal to another. 結果は、true
または false
の値を含む新しい ClaimType ブール値です。The result is a new boolean ClaimType with a value of true
or false
.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaim1inputClaim1 | stringstring | 比較する最初の要求の種類。First claim type, which is to be compared. |
InputClaimInputClaim | inputClaim2inputClaim2 | stringstring | 比較する 2 番目の要求の種類。Second claim type, which is to be compared. |
InputParameterInputParameter | operatoroperator | stringstring | 指定できる値: EQUAL または NOT EQUAL 。Possible values: EQUAL or NOT EQUAL . |
InputParameterInputParameter | ignoreCaseignoreCase | booleanboolean | この比較が比較対象の文字列の大文字と小文字を無視するかどうかを指定します。Specifies whether this comparison should ignore the case of the strings being compared. |
OutputClaimOutputClaim | outputClaimoutputClaim | booleanboolean | この要求変換が呼び出された後に生成される ClaimType。The ClaimType that is produced after this claims transformation has been invoked. |
この要求変換を使用して、要求が別の要求と等しいかどうかをチェックします。Use this claims transformation to check if a claim is equal to another claim. たとえば、以下の要求変換は email 要求の値が Verified.Email 要求と等しいかどうかをチェックします。For example, the following claims transformation checks if the value of the email claim is equal to the Verified.Email claim.
<ClaimsTransformation Id="CheckEmail" TransformationMethod="CompareClaims">
<InputClaims>
<InputClaim ClaimTypeReferenceId="Email" TransformationClaimType="inputClaim1" />
<InputClaim ClaimTypeReferenceId="Verified.Email" TransformationClaimType="inputClaim2" />
</InputClaims>
<InputParameters>
<InputParameter Id="operator" DataType="string" Value="NOT EQUAL" />
<InputParameter Id="ignoreCase" DataType="string" Value="true" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="SameEmailAddress" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim1: someone@contoso.cominputClaim1: someone@contoso.com
- inputClaim2: someone@outlook.cominputClaim2: someone@outlook.com
- 入力パラメーター:Input parameters:
- operator:NOT EQUALoperator: NOT EQUAL
- ignoreCase: trueignoreCase: true
- 出力要求:Output claims:
- outputClaim: trueoutputClaim: true
CompareClaimToValueCompareClaimToValue
要求の値が入力パラメーターの値と等しいかどうかを確認します。Determines whether a claim value is equal to the input parameter value.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaim1inputClaim1 | stringstring | 比較する要求の種類。The claim's type, which is to be compared. |
InputParameterInputParameter | operatoroperator | stringstring | 指定できる値: EQUAL または NOT EQUAL 。Possible values: EQUAL or NOT EQUAL . |
InputParameterInputParameter | compareTocompareTo | stringstring | 文字列比較で、次のいずれかの値です。序数、OrdinalIgnoreCase。string comparison, one of the values: Ordinal, OrdinalIgnoreCase. |
InputParameterInputParameter | ignoreCaseignoreCase | booleanboolean | この比較が比較対象の文字列の大文字と小文字を無視するかどうかを指定します。Specifies whether this comparison should ignore the case of the strings being compared. |
OutputClaimOutputClaim | outputClaimoutputClaim | booleanboolean | この要求変換が呼び出された後に生成される ClaimType。The ClaimType that is produced after this claims transformation has been invoked. |
この要求変換を使用して、要求が、指定した値と等しいかどうかをチェックできます。You can use this claims transformation to check if a claim is equal to a value you specified. たとえば、以下の要求変換は termsOfUseConsentVersion 要求の値が v1
と等しいかどうかをチェックします。For example, the following claims transformation checks if the value of the termsOfUseConsentVersion claim is equal to v1
.
<ClaimsTransformation Id="IsTermsOfUseConsentRequiredForVersion" TransformationMethod="CompareClaimToValue">
<InputClaims>
<InputClaim ClaimTypeReferenceId="termsOfUseConsentVersion" TransformationClaimType="inputClaim1" />
</InputClaims>
<InputParameters>
<InputParameter Id="compareTo" DataType="string" Value="V1" />
<InputParameter Id="operator" DataType="string" Value="not equal" />
<InputParameter Id="ignoreCase" DataType="string" Value="true" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="termsOfUseConsentRequired" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim1: v1inputClaim1: v1
- 入力パラメーター:Input parameters:
- compareTo:V1compareTo: V1
- operator:EQUALoperator: EQUAL
- ignoreCase: trueignoreCase: true
- 出力要求:Output claims:
- outputClaim: trueoutputClaim: true
CreateRandomStringCreateRandomString
乱数ジェネレーターを使用してランダムな文字列を作成します。Creates a random string using the random number generator. 乱数ジェネレーターの種類が integer
の場合、必要に応じてシード パラメーターと最大数を指定できます。If the random number generator is of type integer
, optionally a seed parameter and a maximum number may be provided. 省略可能な文字列形式パラメーターを使用して、出力を書式設定できます。省略可能な base64 パラメーターは、出力が base64 でエンコードされた randomGeneratorType [guid, integer] outputClaim (文字列) であるかどうかを指定します。An optional string format parameter allows the output to be formatted using it, and an optional base64 parameter specifies whether the output is base64 encoded randomGeneratorType [guid, integer] outputClaim (String).
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputParameterInputParameter | randomGeneratorTyperandomGeneratorType | stringstring | 生成されるランダムな値、GUID (グローバル固有 ID) または INTEGER (数字) を指定します。Specifies the random value to be generated, GUID (global unique ID) or INTEGER (a number). |
InputParameterInputParameter | stringFormatstringFormat | stringstring | [省略可能] ランダムな値を書式設定します。[Optional] Format the random value. |
InputParameterInputParameter | base64base64 | booleanboolean | [省略可能] ランダムな値を base64 に変換します。[Optional] Convert the random value to base64. 文字列形式が適用されている場合、文字列形式の後の値は base64 にエンコードされます。If string format is applied, the value after string format is encoded to base64. |
InputParameterInputParameter | maximumNumbermaximumNumber | INTint | [省略可能] INTEGER randomGeneratorType のみです。[Optional] For INTEGER randomGeneratorType only. 最大数を指定します。Specify the maximum number. |
InputParameterInputParameter | seedseed | INTint | [省略可能] INTEGER randomGeneratorType のみです。[Optional] For INTEGER randomGeneratorType only. 乱数値のシードを指定します。Specify the seed for the random value. 注: 同じシードは、同じ乱数のシーケンスを生成します。Note: same seed yields same sequence of random numbers. |
OutputClaimOutputClaim | outputClaimoutputClaim | stringstring | この要求変換が呼び出された後に生成される ClaimTypes。The ClaimTypes that will be produced after this claims transformation has been invoked. ランダムな値。The random value. |
次の例はグローバルな一意の ID を生成します。Following example generates a global unique ID. この要求変換を使用してランダムな UPN (ユーザー プリンシパル名) を作成します。This claims transformation is used to create the random UPN (user principle name).
<ClaimsTransformation Id="CreateRandomUPNUserName" TransformationMethod="CreateRandomString">
<InputParameters>
<InputParameter Id="randomGeneratorType" DataType="string" Value="GUID" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="upnUserName" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力パラメーター:Input parameters:
- randomGeneratorType:GUIDrandomGeneratorType: GUID
- 出力要求:Output claims:
- outputClaim: bc8bedd2-aaa3-411e-bdee-2f1810b73dfcoutputClaim: bc8bedd2-aaa3-411e-bdee-2f1810b73dfc
次の例では、0 ~ 1000 の範囲の整数のランダムな値を生成します。Following example generates an integer random value between 0 and 1000. 値は OTP_{ランダム値} に書式設定されます。The value is formatted to OTP_{random value}.
<ClaimsTransformation Id="SetRandomNumber" TransformationMethod="CreateRandomString">
<InputParameters>
<InputParameter Id="randomGeneratorType" DataType="string" Value="INTEGER" />
<InputParameter Id="maximumNumber" DataType="int" Value="1000" />
<InputParameter Id="stringFormat" DataType="string" Value="OTP_{0}" />
<InputParameter Id="base64" DataType="boolean" Value="false" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="randomNumber" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力パラメーター:Input parameters:
- randomGeneratorType:INTEGERrandomGeneratorType: INTEGER
- maximumNumber:1000maximumNumber: 1000
- stringFormat:OTP_{0}stringFormat: OTP_{0}
- base64: falsebase64: false
- 出力要求:Output claims:
- outputClaim:OTP_853outputClaim: OTP_853
FormatLocalizedStringFormatLocalizedString
指定されたローカライズ済み書式指定文字列に従って、複数の要求の書式を設定します。Format multiple claims according to a provided localized format string. この変換では、C# の String.Format
メソッドを使用します。This transformation uses the C# String.Format
method.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimsInputClaims | stringstring | 文字列形式 {0}、{1}、{2} パラメーターとして機能する一連の入力要求。The collection of input claims that acts as string format {0}, {1}, {2} parameters. | |
InputParameterInputParameter | stringFormatIdstringFormatId | stringstring | ローカライズされた文字列の StringId 。The StringId of a localized string. |
OutputClaimOutputClaim | outputClaimoutputClaim | stringstring | この要求変換が呼び出された後に生成される ClaimType。The ClaimType that is produced after this claims transformation has been invoked. |
注意
文字列形式の最大許容サイズは 4000 です。String format maximum allowed size is 4000.
FormatLocalizedString 要求変換を使用するには:To use the FormatLocalizedString claims transformation:
- ローカライズ文字列を定義し、それをセルフアサート技術プロファイルに関連付けます。Define a localization string, and associate it with a self-asserted-technical-profile.
LocalizedString
要素のElementType
はFormatLocalizedStringTransformationClaimType
に設定する必要があります。TheElementType
of theLocalizedString
element must be set toFormatLocalizedStringTransformationClaimType
.StringId
は、ユーザーが定義する一意識別子であり、後ほど要求変換stringFormatId
で使用します。TheStringId
is a unique identifier that you define, and use it later in your claims transformationstringFormatId
.- 要求変換で、ローカライズされた文字列を使用して設定される要求の一覧を指定します。In the claims transformation, specify the list of claims to be set with the localized string. 次に、
stringFormatId
を ローカライズされた文字列要素のStringId
に設定します。Then set thestringFormatId
to theStringId
of the localized string element. - セルフアサート技術プロファイル、または表示コントロールの入力または出力要求変換で、要求変換への参照を付けます。In a self-asserted technical profile, or a display control input or output claims transformation, make a reference to your claims transformation.
次の例では、アカウントが既にディレクトリに存在する場合にエラー メッセージが生成されます。The following example generates an error message when an account is already in the directory. この例では、英語 (既定値) とスペイン語のローカライズされた文字列が定義されます。The example defines localized strings for English (default) and Spanish.
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="Append">
<SupportedLanguage>en</SupportedLanguage>
<SupportedLanguage>es</SupportedLanguage>
</SupportedLanguages>
<LocalizedResources Id="api.localaccountsignup.en">
<LocalizedStrings>
<LocalizedString ElementType="FormatLocalizedStringTransformationClaimType" StringId="ResponseMessge_EmailExists">The email '{0}' is already an account in this organization. Click Next to sign in with that account.</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
<LocalizedResources Id="api.localaccountsignup.es">
<LocalizedStrings>
<LocalizedString ElementType="FormatLocalizedStringTransformationClaimType" StringId="ResponseMessge_EmailExists">Este correo electrónico "{0}" ya es una cuenta de esta organización. Haga clic en Siguiente para iniciar sesión con esa cuenta.</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>
要求変換では、ローカライズされた文字列に基づいて応答メッセージが作成されます。The claims transformation creates a response message based on the localized string. メッセージには、ローカライズされた文字列 ResponseMessge_EmailExists に埋め込まれているユーザーのメールアドレスが含まれます。The message contains the user's email address embedded into the localized sting ResponseMessge_EmailExists.
<ClaimsTransformation Id="SetResponseMessageForEmailAlreadyExists" TransformationMethod="FormatLocalizedString">
<InputClaims>
<InputClaim ClaimTypeReferenceId="email" />
</InputClaims>
<InputParameters>
<InputParameter Id="stringFormatId" DataType="string" Value="ResponseMessge_EmailExists" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="responseMsg" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim: sarah@contoso.cominputClaim: sarah@contoso.com
- 入力パラメーター:Input parameters:
- stringFormat: ResponseMessge_EmailExistsstringFormat: ResponseMessge_EmailExists
- 出力要求:Output claims:
- Outputclaim: 電子メール 'sarah@contoso.com' は既にこの組織のアカウントです。outputClaim: The email 'sarah@contoso.com' is already an account in this organization. [次へ] をクリックして、そのアカウントでサインインします。Click Next to sign in with that account.
FormatStringClaimFormatStringClaim
指定された書式設定文字列に従って要求の書式を設定します。Format a claim according to the provided format string. この変換では、C# の String.Format
メソッドを使用します。This transformation uses the C# String.Format
method.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaiminputClaim | stringstring | 文字列形式 {0} パラメーターとして機能する ClaimType。The ClaimType that acts as string format {0} parameter. |
InputParameterInputParameter | stringFormatstringFormat | stringstring | {0} パラメーターを含む文字列の形式。The string format, including the {0} parameter. この入力パラメーターは、文字列要求変換式をサポートします。This input parameter supports string claims transformation expressions. |
OutputClaimOutputClaim | outputClaimoutputClaim | stringstring | この要求変換が呼び出された後に生成される ClaimType。The ClaimType that is produced after this claims transformation has been invoked. |
注意
文字列形式の最大許容サイズは 4000 です。String format maximum allowed size is 4000.
この要求変換を使用して 1 つのパラメーター {0} を持つ任意の文字列の書式を設定します。Use this claims transformation to format any string with one parameter {0}. 次の例では、userPrincipalName を作成します。The following example creates a userPrincipalName. Facebook-OAUTH
などのすべてのソーシャル ID プロバイダーの技術プロファイルは、CreateUserPrincipalName を呼び出して userPrincipalName を生成します。All social identity provider technical profiles, such as Facebook-OAUTH
calls the CreateUserPrincipalName to generate a userPrincipalName.
<ClaimsTransformation Id="CreateUserPrincipalName" TransformationMethod="FormatStringClaim">
<InputClaims>
<InputClaim ClaimTypeReferenceId="upnUserName" TransformationClaimType="inputClaim" />
</InputClaims>
<InputParameters>
<InputParameter Id="stringFormat" DataType="string" Value="cpim_{0}@{RelyingPartyTenantId}" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="userPrincipalName" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim:5164db16-3eee-4629-bfda-dcc3326790e9inputClaim: 5164db16-3eee-4629-bfda-dcc3326790e9
- 入力パラメーター:Input parameters:
- stringFormat: cpim_{0}@{RelyingPartyTenantId}stringFormat: cpim_{0}@{RelyingPartyTenantId}
- 出力要求:Output claims:
- outputClaim: cpim_5164db16-3eee-4629-bfda-dcc3326790e9@b2cdemo.onmicrosoft.comoutputClaim: cpim_5164db16-3eee-4629-bfda-dcc3326790e9@b2cdemo.onmicrosoft.com
FormatStringMultipleClaimsFormatStringMultipleClaims
指定された書式設定文字列に従って、2 つの要求の書式を設定します。Format two claims according to the provided format string. この変換では、C# の String.Format
メソッドを使用します。This transformation uses the C# String.Format
method.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaiminputClaim | stringstring | 文字列形式 {0} パラメーターとして機能する ClaimType。The ClaimType that acts as string format {0} parameter. |
InputClaimInputClaim | inputClaiminputClaim | stringstring | 文字列形式 {1} パラメーターとして機能する ClaimType。The ClaimType that acts as string format {1} parameter. |
InputParameterInputParameter | stringFormatstringFormat | stringstring | {0} および {1} パラメーターを含む文字列の形式。The string format, including the {0} and {1} parameters. この入力パラメーターは、文字列要求変換式をサポートします。This input parameter supports string claims transformation expressions. |
OutputClaimOutputClaim | outputClaimoutputClaim | stringstring | この要求変換が呼び出された後に生成される ClaimType。The ClaimType that is produced after this claims transformation has been invoked. |
注意
文字列形式の最大許容サイズは 4000 です。String format maximum allowed size is 4000.
この要求変換を使用して 2 つのパラメーター {0} および {1} を持つ任意の文字列の書式を設定します。Use this claims transformation to format any string with two parameters, {0} and {1}. 次の例では、指定した形式で displayName を作成します。The following example creates a displayName with the specified format:
<ClaimsTransformation Id="CreateDisplayNameFromFirstNameAndLastName" TransformationMethod="FormatStringMultipleClaims">
<InputClaims>
<InputClaim ClaimTypeReferenceId="givenName" TransformationClaimType="inputClaim1" />
<InputClaim ClaimTypeReferenceId="surName" TransformationClaimType="inputClaim2" />
</InputClaims>
<InputParameters>
<InputParameter Id="stringFormat" DataType="string" Value="{0} {1}" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="displayName" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim1:JoeinputClaim1: Joe
- inputClaim2:FernandoinputClaim2: Fernando
- 入力パラメーター:Input parameters:
- stringFormat: {0} {1}stringFormat: {0} {1}
- 出力要求:Output claims:
- outputClaim:Joe FernandooutputClaim: Joe Fernando
GetLocalizedStringsTransformationGetLocalizedStringsTransformation
ローカライズされた文字列を要求にコピーします。Copies localized strings into claims.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
OutputClaimOutputClaim | ローカライズされた文字列の名前The name of the localized string | stringstring | この要求変換が呼び出された後に生成される要求の種類の一覧。List of claim types that are produced after this claims transformation has been invoked. |
GetLocalizedStringsTransformation 要求変換を使用する場合は、次の操作を行います。To use the GetLocalizedStringsTransformation claims transformation:
- ローカライズ文字列を定義し、それをセルフアサート技術プロファイルに関連付けます。Define a localization string and associate it with a self-asserted-technical-profile.
LocalizedString
要素のElementType
はGetLocalizedStringsTransformationClaimType
に設定する必要があります。TheElementType
of theLocalizedString
element must be set toGetLocalizedStringsTransformationClaimType
.StringId
はユーザーが定義する一意識別子であり、後ほど要求変換で使用します。TheStringId
is a unique identifier that you define, and use it later in your claims transformation.- 要求変換で、ローカライズされた文字列を使用して設定される要求の一覧を指定します。In the claims transformation, specify the list of claims to be set with the localized string.
ClaimTypeReferenceId
は、ポリシー内の ClaimsSchema セクションに既に定義されている ClaimType への参照です。TheClaimTypeReferenceId
is a reference to a ClaimType already defined in the ClaimsSchema section in the policy.TransformationClaimType
は、LocalizedString
要素のStringId
で定義されているローカライズされた文字列の名前です。TheTransformationClaimType
is the name of the localized string as defined in theStringId
of theLocalizedString
element. - セルフアサート技術プロファイル、または表示コントロールの入力または出力要求変換で、要求変換への参照を付けます。In a self-asserted technical profile, or a display control input or output claims transformation, make a reference to your claims transformation.
次の例では、ローカライズされた文字列から電子メールの件名、本文、コード メッセージ、電子メールの署名を検索します。The following example looks up the email subject, body, your code message, and the signature of the email, from localized strings. これらの要求は、後でカスタム メール確認テンプレートによって使用されます。These claims later used by custom email verification template.
英語 (既定値) とスペイン語のローカライズされた文字列を定義します。Define localized strings for English (default) and Spanish.
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="Append">
<SupportedLanguage>en</SupportedLanguage>
<SupportedLanguage>es</SupportedLanguage>
</SupportedLanguages>
<LocalizedResources Id="api.localaccountsignup.en">
<LocalizedStrings>
<LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_subject">Contoso account email verification code</LocalizedString>
<LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_message">Thanks for verifying your account!</LocalizedString>
<LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_code">Your code is</LocalizedString>
<LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_signature">Sincerely</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
<LocalizedResources Id="api.localaccountsignup.es">
<LocalizedStrings>
<LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_subject">Código de verificación del correo electrónico de la cuenta de Contoso</LocalizedString>
<LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_message">Gracias por comprobar la cuenta de </LocalizedString>
<LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_code">Su código es</LocalizedString>
<LocalizedString ElementType="GetLocalizedStringsTransformationClaimType" StringId="email_signature">Atentamente</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>
要求変換では、StringId
email_subject の値を使用して要求の種類 subject の値が設定されます。The claims transformation sets the value of the claim type subject with the value of the StringId
email_subject.
<ClaimsTransformation Id="GetLocalizedStringsForEmail" TransformationMethod="GetLocalizedStringsTransformation">
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="subject" TransformationClaimType="email_subject" />
<OutputClaim ClaimTypeReferenceId="message" TransformationClaimType="email_message" />
<OutputClaim ClaimTypeReferenceId="codeIntro" TransformationClaimType="email_code" />
<OutputClaim ClaimTypeReferenceId="signature" TransformationClaimType="email_signature" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 出力要求:Output claims:
- subject: Contoso アカウントの電子メール確認コードsubject: Contoso account email verification code
- message:アカウントの確認が完了しました!message: Thanks for verifying your account!
- codeIntro:お客様のコードcodeIntro: Your code is
- signature:ご利用ありがとうございますsignature: Sincerely
GetMappedValueFromLocalizedCollectionGetMappedValueFromLocalizedCollection
要求 Restriction コレクションからの項目の検索。Looking up an item from a claim Restriction collection.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | mapFromClaimmapFromClaim | stringstring | Restriction コレクションがある restrictionValueClaim 要求から検索するテキストを含む要求。The claim that contains the text to be looked up in the restrictionValueClaim claims with the Restriction collection. |
OutputClaimOutputClaim | restrictionValueClaimrestrictionValueClaim | stringstring | Restriction コレクションが含まれる要求。The claim that contains the Restriction collection. 要求変換が呼び出された後には、この要求の値には、選択した項目の値が含まれます。After the claims transformation has been invoked, the value of this claim contains the value of the selected item. |
次の例では、エラーのキーに基づいて、エラー メッセージの説明を検索します。The following example looks up the error message description based on the error key. responseMsg 要求には、エンド ユーザーに提示する、または証明書利用者に送信するエラー メッセージのコレクションが含まれています。The responseMsg claim contains a collection of error messages to present to the end user or to be sent to the relying party.
<ClaimType Id="responseMsg">
<DisplayName>Error message: </DisplayName>
<DataType>string</DataType>
<UserInputType>Paragraph</UserInputType>
<Restriction>
<Enumeration Text="B2C_V1_90001" Value="You cannot sign in because you are a minor" />
<Enumeration Text="B2C_V1_90002" Value="This action can only be performed by gold members" />
<Enumeration Text="B2C_V1_90003" Value="You have not been enabled for this operation" />
</Restriction>
</ClaimType>
要求変換では、項目のテキストを検索し、その値を返します。The claims transformation looks up the text of the item and returns its value. 制限が <LocalizedCollection>
を使用してローカライズされている場合、要求変換はローカライズされた値を返します。If the restriction is localized using <LocalizedCollection>
, the claims transformation returns the localized value.
<ClaimsTransformation Id="GetResponseMsgMappedToResponseCode" TransformationMethod="GetMappedValueFromLocalizedCollection">
<InputClaims>
<InputClaim ClaimTypeReferenceId="responseCode" TransformationClaimType="mapFromClaim" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="responseMsg" TransformationClaimType="restrictionValueClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- mapFromClaim:B2C_V1_90001mapFromClaim: B2C_V1_90001
- 出力要求:Output claims:
- restrictionValueClaim:マイナーであるのでサインインできません。restrictionValueClaim: You cannot sign in because you are a minor.
LookupValueLookupValue
別の要求の値に基づいて、値の一覧から要求の値を検索します。Look up a claim value from a list of values based on the value of another claim.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputParameterIdinputParameterId | stringstring | 参照値が含まれる要求The claim that contains the lookup value |
InputParameterInputParameter | stringstring | inputParameters のコレクションです。Collection of inputParameters. | |
InputParameterInputParameter | errorOnFailedLookuperrorOnFailedLookup | booleanboolean | 一致参照がない場合にエラーが返されるかどうかを制御します。Controlling whether an error is returned when no matching lookup. |
OutputClaimOutputClaim | inputParameterIdinputParameterId | stringstring | この要求変換が呼び出された後に生成される ClaimTypes。The ClaimTypes that will be produced after this claims transformation has been invoked. 一致する Id の値。The value of the matching Id . |
次の例では、inpuParameters コレクションの 1 つからドメイン名を検索します。The following example looks up the domain name in one of the inputParameters collections. 要求変換では、識別子内のドメイン名を検索し、その値 (アプリケーション ID) を返します。The claims transformation looks up the domain name in the identifier and returns its value (an application ID).
<ClaimsTransformation Id="DomainToClientId" TransformationMethod="LookupValue">
<InputClaims>
<InputClaim ClaimTypeReferenceId="domainName" TransformationClaimType="inputParameterId" />
</InputClaims>
<InputParameters>
<InputParameter Id="contoso.com" DataType="string" Value="13c15f79-8fb1-4e29-a6c9-be0d36ff19f1" />
<InputParameter Id="microsoft.com" DataType="string" Value="0213308f-17cb-4398-b97e-01da7bd4804e" />
<InputParameter Id="test.com" DataType="string" Value="c7026f88-4299-4cdb-965d-3f166464b8a9" />
<InputParameter Id="errorOnFailedLookup" DataType="boolean" Value="false" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="domainAppId" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputParameterId: test.cominputParameterId: test.com
- 入力パラメーター:Input parameters:
- contoso.com:13c15f79-8fb1-4e29-a6c9-be0d36ff19f1contoso.com: 13c15f79-8fb1-4e29-a6c9-be0d36ff19f1
- microsoft.com:0213308f-17cb-4398-b97e-01da7bd4804emicrosoft.com: 0213308f-17cb-4398-b97e-01da7bd4804e
- test.com: c7026f88-4299-4cdb-965d-3f166464b8a9test.com: c7026f88-4299-4cdb-965d-3f166464b8a9
- errorOnFailedLookup: falseerrorOnFailedLookup: false
- 出力要求:Output claims:
- outputClaim: c7026f88-4299-4cdb-965d-3f166464b8a9outputClaim: c7026f88-4299-4cdb-965d-3f166464b8a9
errorOnFailedLookup
入力パラメーターが true
に設定されると、LookupValue 要求変換は常に、セルフアサート技術プロファイルによって呼び出される 検証技術プロファイル (つまり DisplayConrtol) から実行されます。When errorOnFailedLookup
input parameter is set to true
, the LookupValue claims transformation is always executed from a validation technical profile that is called by a self-asserted technical profile, or a DisplayConrtol. ユーザーに表示されるエラー メッセージは、セルフアサート技術プロファイルの LookupNotFound
メタデータによって制御されます。The LookupNotFound
metadata of a self-asserted technical profile controls the error message that is presented to the user.
次の例では、inpuParameters コレクションの 1 つからドメイン名を検索します。The following example looks up the domain name in one of the inputParameters collections. 要求変換では、識別子内のドメイン名を検索し、その値 (アプリケーション ID) を返します。つまり、エラー メッセージが生成されます。The claims transformation looks up the domain name in the identifier and returns its value (an application ID), or raises an error message.
<ClaimsTransformation Id="DomainToClientId" TransformationMethod="LookupValue">
<InputClaims>
<InputClaim ClaimTypeReferenceId="domainName" TransformationClaimType="inputParameterId" />
</InputClaims>
<InputParameters>
<InputParameter Id="contoso.com" DataType="string" Value="13c15f79-8fb1-4e29-a6c9-be0d36ff19f1" />
<InputParameter Id="microsoft.com" DataType="string" Value="0213308f-17cb-4398-b97e-01da7bd4804e" />
<InputParameter Id="test.com" DataType="string" Value="c7026f88-4299-4cdb-965d-3f166464b8a9" />
<InputParameter Id="errorOnFailedLookup" DataType="boolean" Value="true" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="domainAppId" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputParameterId: live.cominputParameterId: live.com
- 入力パラメーター:Input parameters:
- contoso.com:13c15f79-8fb1-4e29-a6c9-be0d36ff19f1contoso.com: 13c15f79-8fb1-4e29-a6c9-be0d36ff19f1
- microsoft.com:0213308f-17cb-4398-b97e-01da7bd4804emicrosoft.com: 0213308f-17cb-4398-b97e-01da7bd4804e
- test.com: c7026f88-4299-4cdb-965d-3f166464b8a9test.com: c7026f88-4299-4cdb-965d-3f166464b8a9
- errorOnFailedLookup: trueerrorOnFailedLookup: true
- エラー:Error:
- 一連の入力パラメーターの ID に入力要求値との一致が見つかりませんでした。また、errorOnFailedLookup は true になっています。No match found for the input claim value in the list of input parameter ids and errorOnFailedLookup is true.
NullClaimNullClaim
特定の要求の値を消去します。Clean the value of a given claim.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
OutputClaimOutputClaim | claim_to_nullclaim_to_null | stringstring | 要求の値を Null に設定します。The claim's value is set to NULL. |
この要求変換を使用して、不要なデータを要求プロパティ バッグから削除し、セッション Cookie のサイズを縮小します。Use this claim transformation to remove unnecessary data from the claims property bag so the session cookie will be smaller. 次の例では、TermsOfService
要求の種類の値を削除します。The following example removes the value of the TermsOfService
claim type.
<ClaimsTransformation Id="SetTOSToNull" TransformationMethod="NullClaim">
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="TermsOfService" TransformationClaimType="claim_to_null" />
</OutputClaims>
</ClaimsTransformation>
- 入力要求:Input claims:
- outputClaim:Welcome to Contoso App.outputClaim: Welcome to Contoso App. この Web サイトを継続して参照および使用する場合には、次の使用条件に従い、制約を受けることに同意していただくものとします。If you continue to browse and use this website, you are agreeing to comply with and be bound by the following terms and conditions...
- 出力要求:Output claims:
- outputClaim:NULLoutputClaim: NULL
ParseDomainParseDomain
電子メール アドレスのドメイン部分を取得します。Gets the domain portion of an email address.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | emailAddressemailAddress | stringstring | 電子メール アドレスが含まれている ClaimType。The ClaimType that contains the email address. |
OutputClaimOutputClaim | domaindomain | stringstring | この要求変換が呼び出された後に生成される ClaimType - ドメイン。The ClaimType that is produced after this claims transformation has been invoked - the domain. |
この要求変換は、ユーザーの @ 記号の後のドメイン名を解析するために使用します。Use this claims transformation to parse the domain name after the @ symbol of the user. 次の要求変換は、email 要求からドメイン名を解析する方法を示しています。The following claims transformation demonstrates how to parse the domain name from an email claim.
<ClaimsTransformation Id="SetDomainName" TransformationMethod="ParseDomain">
<InputClaims>
<InputClaim ClaimTypeReferenceId="email" TransformationClaimType="emailAddress" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="domainName" TransformationClaimType="domain" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- emailAddress: joe@outlook.comemailAddress: joe@outlook.com
- 出力要求:Output claims:
- domain: outlook.comdomain: outlook.com
SetClaimsIfRegexMatchSetClaimsIfRegexMatch
文字列の要求の claimToMatch
と matchTo
の入力パラメーターが等しいことをチェックし、出力要求を outputClaimIfMatched
入力パラメーターにある値で設定します。同時に結果の出力要求を比較します。これは比較の結果に基づいて true
または false
として設定されます。Checks that a string claim claimToMatch
and matchTo
input parameter are equal, and sets the output claims with the value present in outputClaimIfMatched
input parameter, along with compare result output claim, which is to be set as true
or false
based on the result of comparison.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
inputClaiminputClaim | claimToMatchclaimToMatch | stringstring | 比較する要求の種類。The claim type, which is to be compared. |
InputParameterInputParameter | matchTomatchTo | stringstring | 照合する正規表現。The regular expression to match. |
InputParameterInputParameter | outputClaimIfMatchedoutputClaimIfMatched | stringstring | 文字列が等しい場合に設定する値。The value to be set if strings are equal. |
InputParameterInputParameter | extractGroupsextractGroups | booleanboolean | [省略可能] Regex の一致でグループ値を抽出するかどうかを指定します。[Optional] Specifies whether the Regex match should extract groups values. 指定できる値: true または false (既定値)。Possible values: true , or false (default). |
OutputClaimOutputClaim | outputClaimoutputClaim | stringstring | 正規表現が一致する場合は、この出力要求に outputClaimIfMatched 入力パラメーターの値が含まれます。If regular expression is match, this output claim contains the value of outputClaimIfMatched input parameter. 一致するものがない場合は null になります。Or null, if no match. |
OutputClaimOutputClaim | regexCompareResultClaimregexCompareResultClaim | booleanboolean | 正規表現で結果の出力要求の種類が照合されます。これは照合の結果に基づいて、true または false として設定されます。The regular expression match result output claim type, which is to be set as true or false based on the result of matching. |
OutputClaimOutputClaim | 要求の名前The name of the claim | stringstring | extractGroups 入力パラメーターが true に設定されている場合は、この要求変換が呼び出された後に生成される要求の種類の一覧です。If the extractGroups input parameter set to true, list of claim types that are produced after this claims transformation has been invoked. claimType の名前は、Regex グループ名と一致する必要があります。The name of the claimType must match the Regex group name. |
例 1Example 1
電話番号の正規表現パターンに基づいて、指定された電話番号が有効かどうかをチェックします。Checks whether the provided phone number is valid, based on phone number regular expression pattern.
<ClaimsTransformation Id="SetIsPhoneRegex" TransformationMethod="SetClaimsIfRegexMatch">
<InputClaims>
<InputClaim ClaimTypeReferenceId="phone" TransformationClaimType="claimToMatch" />
</InputClaims>
<InputParameters>
<InputParameter Id="matchTo" DataType="string" Value="^[0-9]{4,16}$" />
<InputParameter Id="outputClaimIfMatched" DataType="string" Value="isPhone" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="validationResult" TransformationClaimType="outputClaim" />
<OutputClaim ClaimTypeReferenceId="isPhoneBoolean" TransformationClaimType="regexCompareResultClaim" />
</OutputClaims>
</ClaimsTransformation>
- 入力要求:Input claims:
- claimToMatch:"64854114520"claimToMatch: "64854114520"
- 入力パラメーター:Input parameters:
- matchTo: "^[0-9]{4,16}$"matchTo: "^[0-9]{4,16}$"
- outputClaimIfMatched: "isPhone"outputClaimIfMatched: "isPhone"
- 出力要求:Output claims:
- outputClaim: "isPhone"outputClaim: "isPhone"
- regexCompareResultClaim: trueregexCompareResultClaim: true
例 2Example 2
指定された電子メール アドレスが有効かどうかを確認し、電子メールの別名を返します。Checks whether the provided email address is valid, and return the email alias.
<ClaimsTransformation Id="GetAliasFromEmail" TransformationMethod="SetClaimsIfRegexMatch">
<InputClaims>
<InputClaim ClaimTypeReferenceId="email" TransformationClaimType="claimToMatch" />
</InputClaims>
<InputParameters>
<InputParameter Id="matchTo" DataType="string" Value="(?<mailAlias>.*)@(.*)$" />
<InputParameter Id="outputClaimIfMatched" DataType="string" Value="isEmail" />
<InputParameter Id="extractGroups" DataType="boolean" Value="true" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="validationResult" TransformationClaimType="outputClaim" />
<OutputClaim ClaimTypeReferenceId="isEmailString" TransformationClaimType="regexCompareResultClaim" />
<OutputClaim ClaimTypeReferenceId="mailAlias" />
</OutputClaims>
</ClaimsTransformation>
- 入力要求:Input claims:
- claimToMatch: "emily@contoso.com"claimToMatch: "emily@contoso.com"
- 入力パラメーター:Input parameters:
- matchTo:
(?<mailAlias>.*)@(.*)$
matchTo:(?<mailAlias>.*)@(.*)$
- outputClaimIfMatched: "isEmail"outputClaimIfMatched: "isEmail"
- extractGroups: trueextractGroups: true
- matchTo:
- 出力要求:Output claims:
- outputClaim: "isEmail"outputClaim: "isEmail"
- regexCompareResultClaim: trueregexCompareResultClaim: true
- mailAlias: emilymailAlias: emily
SetClaimsIfStringsAreEqualSetClaimsIfStringsAreEqual
文字列の要求と matchTo
入力パラメーターが等しいことをチェックし、出力要求を stringMatchMsg
および stringMatchMsgCode
入力パラメーターにある値で設定します。同時に結果の出力要求を比較します。これは比較の結果に基づいて true
または false
として設定されます。Checks that a string claim and matchTo
input parameter are equal, and sets the output claims with the value present in stringMatchMsg
and stringMatchMsgCode
input parameters, along with compare result output claim, which is to be set as true
or false
based on the result of comparison.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaiminputClaim | stringstring | 比較する要求の種類。The claim type, which is to be compared. |
InputParameterInputParameter | matchTomatchTo | stringstring | inputClaim と比較する文字列。The string to be compared with inputClaim . |
InputParameterInputParameter | stringComparisonstringComparison | stringstring | 指定できる値: Ordinal または OrdinalIgnoreCase 。Possible values: Ordinal or OrdinalIgnoreCase . |
InputParameterInputParameter | stringMatchMsgstringMatchMsg | stringstring | 文字列が等しい場合に設定する最初の値。First value to be set if strings are equal. |
InputParameterInputParameter | stringMatchMsgCodestringMatchMsgCode | stringstring | 文字列が等しい場合に設定する 2 番目の値。Second value to be set if strings are equal. |
OutputClaimOutputClaim | outputClaim1outputClaim1 | stringstring | 文字列が等しい場合は、この出力要求に stringMatchMsg 入力パラメーターの値が含まれます。If strings are equals, this output claim contains the value of stringMatchMsg input parameter. |
OutputClaimOutputClaim | outputClaim2outputClaim2 | stringstring | 文字列が等しい場合は、この出力要求に stringMatchMsgCode 入力パラメーターの値が含まれます。If strings are equals, this output claim contains the value of stringMatchMsgCode input parameter. |
OutputClaimOutputClaim | stringCompareResultClaimstringCompareResultClaim | booleanboolean | 比較の結果の出力要求の種類。これは比較の結果に基づいて、true または false として設定されます。The compare result output claim type, which is to be set as true or false based on the result of comparison. |
この要求変換を使用して、要求が、指定した値と等しいかどうかをチェックできます。You can use this claims transformation to check if a claim is equal to value you specified. たとえば、以下の要求変換は termsOfUseConsentVersion 要求の値が v1
と等しいかどうかをチェックします。For example, the following claims transformation checks if the value of the termsOfUseConsentVersion claim is equal to v1
. 等しい場合、値を v2
に変更します。If yes, change the value to v2
.
<ClaimsTransformation Id="CheckTheTOS" TransformationMethod="SetClaimsIfStringsAreEqual">
<InputClaims>
<InputClaim ClaimTypeReferenceId="termsOfUseConsentVersion" TransformationClaimType="inputClaim" />
</InputClaims>
<InputParameters>
<InputParameter Id="matchTo" DataType="string" Value="v1" />
<InputParameter Id="stringComparison" DataType="string" Value="ordinalIgnoreCase" />
<InputParameter Id="stringMatchMsg" DataType="string" Value="B2C_V1_90005" />
<InputParameter Id="stringMatchMsgCode" DataType="string" Value="The TOS is upgraded to v2" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="termsOfUseConsentVersion" TransformationClaimType="outputClaim1" />
<OutputClaim ClaimTypeReferenceId="termsOfUseConsentVersionUpgradeCode" TransformationClaimType="outputClaim2" />
<OutputClaim ClaimTypeReferenceId="termsOfUseConsentVersionUpgradeResult" TransformationClaimType="stringCompareResultClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim: v1inputClaim: v1
- 入力パラメーター:Input parameters:
- matchTo:V1matchTo: V1
- stringComparison: ordinalIgnoreCasestringComparison: ordinalIgnoreCase
- stringMatchMsg:B2C_V1_90005stringMatchMsg: B2C_V1_90005
- stringMatchMsgCode:TOS は v2 にアップグレードされますstringMatchMsgCode: The TOS is upgraded to v2
- 出力要求:Output claims:
- outputClaim1:B2C_V1_90005outputClaim1: B2C_V1_90005
- outputClaim2:TOS は v2 にアップグレードされますoutputClaim2: The TOS is upgraded to v2
- stringCompareResultClaim: truestringCompareResultClaim: true
SetClaimsIfStringsMatchSetClaimsIfStringsMatch
文字列の要求と matchTo
入力パラメーターが等しいことをチェックし、出力要求を outputClaimIfMatched
入力パラメーターにある値で設定します。同時に結果の出力要求を比較します。これは比較の結果に基づいて true
または false
として設定されます。Checks that a string claim and matchTo
input parameter are equal, and sets the output claims with the value present in outputClaimIfMatched
input parameter, along with compare result output claim, which is to be set as true
or false
based on the result of comparison.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | claimToMatchclaimToMatch | stringstring | 比較する要求の種類。The claim type, which is to be compared. |
InputParameterInputParameter | matchTomatchTo | stringstring | inputClaim と比較する文字列。The string to be compared with inputClaim. |
InputParameterInputParameter | stringComparisonstringComparison | stringstring | 指定できる値: Ordinal または OrdinalIgnoreCase 。Possible values: Ordinal or OrdinalIgnoreCase . |
InputParameterInputParameter | outputClaimIfMatchedoutputClaimIfMatched | stringstring | 文字列が等しい場合に設定する値。The value to be set if strings are equal. |
OutputClaimOutputClaim | outputClaimoutputClaim | stringstring | 文字列が等しい場合は、この出力要求に outputClaimIfMatched 入力パラメーターの値が含まれます。If strings are equals, this output claim contains the value of outputClaimIfMatched input parameter. または、文字列が一致しない場合は null です。Or null, if the strings aren't match. |
OutputClaimOutputClaim | stringCompareResultClaimstringCompareResultClaim | booleanboolean | 比較の結果の出力要求の種類。これは比較の結果に基づいて、true または false として設定されます。The compare result output claim type, which is to be set as true or false based on the result of comparison. |
たとえば、以下の要求変換は ageGroup 要求の値が Minor
と等しいかどうかをチェックします。For example, the following claims transformation checks if the value of ageGroup claim is equal to Minor
. 等しい場合は、値を B2C_V1_90001
に返します。If yes, return the value to B2C_V1_90001
.
<ClaimsTransformation Id="SetIsMinor" TransformationMethod="SetClaimsIfStringsMatch">
<InputClaims>
<InputClaim ClaimTypeReferenceId="ageGroup" TransformationClaimType="claimToMatch" />
</InputClaims>
<InputParameters>
<InputParameter Id="matchTo" DataType="string" Value="Minor" />
<InputParameter Id="stringComparison" DataType="string" Value="ordinalIgnoreCase" />
<InputParameter Id="outputClaimIfMatched" DataType="string" Value="B2C_V1_90001" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="isMinor" TransformationClaimType="outputClaim" />
<OutputClaim ClaimTypeReferenceId="isMinorResponseCode" TransformationClaimType="stringCompareResultClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- claimToMatch:MinorclaimToMatch: Minor
- 入力パラメーター:Input parameters:
- matchTo:MinormatchTo: Minor
- stringComparison: ordinalIgnoreCasestringComparison: ordinalIgnoreCase
- outputClaimIfMatched:B2C_V1_90001outputClaimIfMatched: B2C_V1_90001
- 出力要求:Output claims:
- isMinorResponseCode:B2C_V1_90001isMinorResponseCode: B2C_V1_90001
- isMinor: trueisMinor: true
StringContainsStringContains
指定した substring が入力要求内に出現しているかどうかが確認されます。Determine whether a specified substring occurs within the input claim. 結果は、true
または false
の値を含む新しい ClaimType ブール値です。The result is a new boolean ClaimType with a value of true
or false
. 値パラメーターがこの文字列内に存在する場合は true
、それ以外の場合は false
。true
if the value parameter occurs within this string, otherwise, false
.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaiminputClaim | stringstring | 検索する要求の種類。The claim type, which is to be searched. |
InputParameterInputParameter | containscontains | stringstring | 検索する値。The value to search. |
InputParameterInputParameter | ignoreCaseignoreCase | stringstring | この比較で比較対象の文字列の大文字と小文字を無視するかどうかを指定します。Specifies whether this comparison should ignore the case of the string being compared. |
OutputClaimOutputClaim | outputClaimoutputClaim | stringstring | この ClaimsTransformation が呼び出された後に生成される ClaimType。The ClaimType that is produced after this ClaimsTransformation has been invoked. 入力要求内で substring が出現した場合のブール値インジケーター。A boolean indicator if the substring occurs within the input claim. |
この要求変換は、文字列要求の種類に substring が含まれているかどうかをチェックする場合に使用します。Use this claims transformation to check if a string claim type contains a substring. 次の例では、roles
文字列要求の種類に admin の値が含まれているかどうかをチェックしています。Following example, checks whether the roles
string claim type contains the value of admin.
<ClaimsTransformation Id="CheckIsAdmin" TransformationMethod="StringContains">
<InputClaims>
<InputClaim ClaimTypeReferenceId="roles" TransformationClaimType="inputClaim"/>
</InputClaims>
<InputParameters>
<InputParameter Id="contains" DataType="string" Value="admin"/>
<InputParameter Id="ignoreCase" DataType="string" Value="true"/>
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="isAdmin" TransformationClaimType="outputClaim"/>
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim:"Admin, Approver, Editor"inputClaim: "Admin, Approver, Editor"
- 入力パラメーター:Input parameters:
- contains: "admin,"contains: "admin,"
- ignoreCase: trueignoreCase: true
- 出力要求:Output claims:
- outputClaim: trueoutputClaim: true
StringSubstringStringSubstring
指定した位置にある文字から始まる文字列要求の種類の一部が抽出され、指定した文字数が返されます。Extracts parts of a string claim type, beginning at the character at the specified position, and returns the specified number of characters.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaiminputClaim | stringstring | 文字列を含む要求の種類。The claim type, which contains the string. |
InputParameterInputParameter | startIndexstartIndex | INTint | このインスタンス内の substring の 0 から始まる開始文字位置。The zero-based starting character position of a substring in this instance. |
InputParameterInputParameter | lengthlength | INTint | substring の文字数。The number of characters in the substring. |
OutputClaimOutputClaim | outputClaimoutputClaim | booleanboolean | このインスタンスの startIndex から始まる長さの substring と等価な文字列。startIndex がこのインスタンスの長さと等しく、length がゼロの場合は空になります。A string that is equivalent to the substring of length that begins at startIndex in this instance, or Empty if startIndex is equal to the length of this instance and length is zero. |
たとえば、電話番号の国または地域のプレフィックスを取得します。For example, get the phone number country/region prefix.
<ClaimsTransformation Id="GetPhonePrefix" TransformationMethod="StringSubstring">
<InputClaims>
<InputClaim ClaimTypeReferenceId="phoneNumber" TransformationClaimType="inputClaim" />
</InputClaims>
<InputParameters>
<InputParameter Id="startIndex" DataType="int" Value="0" />
<InputParameter Id="length" DataType="int" Value="2" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="phonePrefix" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim: "+1644114520"inputClaim: "+1644114520"
- 入力パラメーター:Input parameters:
- startIndex: 0startIndex: 0
- length: 2length: 2
- 出力要求:Output claims:
- outputClaim: "+1"outputClaim: "+1"
StringReplaceStringReplace
要求の種類の文字列で指定した値が検索され、新しい要求の種類の文字列が返されます。ここでは、現在の文字列内の指定した文字列のすべての出現箇所が、別の指定した文字列に置き換えられます。Searches a claim type string for a specified value, and returns a new claim type string in which all occurrences of a specified string in the current string are replaced with another specified string.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaiminputClaim | stringstring | 文字列を含む要求の種類。The claim type, which contains the string. |
InputParameterInputParameter | oldValueoldValue | stringstring | 検索対象の文字列。The string to be searched. |
InputParameterInputParameter | newValuenewValue | stringstring | 出現するすべての oldValue を置換する文字列The string to replace all occurrences of oldValue |
OutputClaimOutputClaim | outputClaimoutputClaim | booleanboolean | oldValue のすべてのインスタンスが newValue で置き換えられることを除いて、現在の文字列と等価な文字列。A string that is equivalent to the current string except that all instances of oldValue are replaced with newValue. oldValue が現在のインスタンス内に見つからない場合、メソッドにより現在のインスタンスが変更せずに返されます。If oldValue is not found in the current instance, the method returns the current instance unchanged. |
たとえば、電話番号の -
文字が削除されて正規化されますFor example, normalize a phone number, by removing the -
characters
<ClaimsTransformation Id="NormalizePhoneNumber" TransformationMethod="StringReplace">
<InputClaims>
<InputClaim ClaimTypeReferenceId="phoneNumber" TransformationClaimType="inputClaim" />
</InputClaims>
<InputParameters>
<InputParameter Id="oldValue" DataType="string" Value="-" />
<InputParameter Id="newValue" DataType="string" Value="" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="phoneNumber" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim: "+164-411-452-054"inputClaim: "+164-411-452-054"
- 入力パラメーター:Input parameters:
- oldValue: "-"oldValue: "-"
- newValue: ""newValue: ""
- 出力要求:Output claims:
- outputClaim: "+164411452054"outputClaim: "+164411452054"
StringJoinStringJoin
指定した文字列コレクションの要求の種類の要素を連結します。各要素またはメンバーの間には、指定した区切り記号が使用されます。Concatenates the elements of a specified string collection claim type, using the specified separator between each element or member.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaiminputClaim | stringCollectionstringCollection | 連結する文字列を格納しているコレクション。A collection that contains the strings to concatenate. |
InputParameterInputParameter | delimiterdelimiter | stringstring | 区切り記号として使用する文字列 (コンマ , など)。The string to use as a separator, such as comma , . |
OutputClaimOutputClaim | outputClaimoutputClaim | stringstring | inputClaim 文字列コレクションのメンバーからなる、delimiter 入力パラメーターで区切られた文字列。A string that consists of the members of the inputClaim string collection, delimited by the delimiter input parameter. |
次の例では、ユーザー ロールの文字列コレクションが取得され、それがコンマ区切り文字列に変換されています。The following example takes a string collection of user roles, and converts it to a comma delimiter string. このメソッドを使用して、Azure AD ユーザー アカウントに文字列コレクションを格納することができます。You can use this method to store a string collection in Azure AD user account. 後でディレクトリからアカウントを読み取るときに、StringSplit
を使用してコンマ区切り文字列を文字列コレクションに戻します。Later, when you read the account from the directory, use the StringSplit
to convert the comma delimiter string back to string collection.
<ClaimsTransformation Id="ConvertRolesStringCollectionToCommaDelimiterString" TransformationMethod="StringJoin">
<InputClaims>
<InputClaim ClaimTypeReferenceId="roles" TransformationClaimType="inputClaim" />
</InputClaims>
<InputParameters>
<InputParameter DataType="string" Id="delimiter" Value="," />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="rolesCommaDelimiterConverted" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim: [ "Admin", "Author", "Reader" ]inputClaim: [ "Admin", "Author", "Reader" ]
- 入力パラメーター:Input parameters:
- delimiter: ","delimiter: ","
- 出力要求:Output claims:
- outputClaim:"Admin,Author,Reader"outputClaim: "Admin,Author,Reader"
StringSplitStringSplit
指定された文字列の要素で区切られた、このインスタンスの substring を格納する文字列配列が返されます。Returns a string array that contains the substrings in this instance that are delimited by elements of a specified string.
ItemItem | TransformationClaimTypeTransformationClaimType | データ型Data Type | NotesNotes |
---|---|---|---|
InputClaimInputClaim | inputClaiminputClaim | stringstring | 分割する substring を含む文字列要求の種類。A string claim type that contains the sub strings to split. |
InputParameterInputParameter | delimiterdelimiter | stringstring | 区切り記号として使用する文字列 (コンマ , など)。The string to use as a separator, such as comma , . |
OutputClaimOutputClaim | outputClaimoutputClaim | stringCollectionstringCollection | delimiter 入力パラメーターで区切られた文字列の要素に substring を格納する文字列コレクション。A string collection whose elements contain the substrings in this string that are delimited by the delimiter input parameter. |
次の例では、ユーザー ロールのコンマ区切り文字列が取得され、それが文字列コレクションに変換されています。The following example takes a comma delimiter string of user roles, and converts it to a string collection.
<ClaimsTransformation Id="ConvertRolesToStringCollection" TransformationMethod="StringSplit">
<InputClaims>
<InputClaim ClaimTypeReferenceId="rolesCommaDelimiter" TransformationClaimType="inputClaim" />
</InputClaims>
<InputParameters>
<InputParameter DataType="string" Id="delimiter" Value="," />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="roles" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
例Example
- 入力要求:Input claims:
- inputClaim:"Admin,Author,Reader"inputClaim: "Admin,Author,Reader"
- 入力パラメーター:Input parameters:
- delimiter: ","delimiter: ","
- 出力要求:Output claims:
- outputClaim: [ "Admin", "Author", "Reader" ]outputClaim: [ "Admin", "Author", "Reader" ]
文字列要求変換式String claim transformations expressions
Azure AD B2C のカスタム ポリシーにおける要求変換式は、テナント ID と技術プロファイル ID についてのコンテキスト情報を提供します。Claim transformations expressions in Azure AD B2C custom policies provide context information about the tenant ID and technical profile ID.
式Expression | 説明Description | 例Example |
---|---|---|
{TechnicalProfileId} |
技術プロファイル ID の名前。The technical profileId name. | Facebook-OAUTHFacebook-OAUTH |
{RelyingPartyTenantId} |
証明書利用者ポリシーのテナント ID。The tenant ID of the relying party policy. | your-tenant.onmicrosoft.comyour-tenant.onmicrosoft.com |
{TrustFrameworkTenantId} |
信頼フレームワークのテナント ID。The tenant ID of the trust framework. | your-tenant.onmicrosoft.comyour-tenant.onmicrosoft.com |