次の方法で共有


Azure Active Directory B2C カスタム ポリシーで Microsoft Entra 技術プロファイルを定義する

重要

2025 年 5 月 1 日より、Azure AD B2C は新規のお客様向けに購入できなくなります。 詳細については、FAQ を参照してください

Azure Active Directory B2C で、カスタム ポリシーは、主に、複雑なシナリオに取り組む用途向けに設計されています。 ほとんどのシナリオで、組み込みユーザー フローを使用することをお勧めします。 まだ行っていない場合は、Active Directory B2C でのカスタム ポリシーの概要に関する記事で、カスタム ポリシー スターター パックの詳細を確認してください。

Azure Active Directory B2C (Azure AD B2C) は、Microsoft Entra ユーザー管理のサポートを提供します。 この記事では、この標準化されたプロトコルをサポートするクレーム プロバイダーと対話するための技術プロファイルの詳細について説明します。

プロトコル

Protocol 要素の Name 属性は Proprietary に設定する必要があります。 ハンドラー属性には、プロトコル ハンドラー アセンブリ Web.TPEngine.Providers.AzureActiveDirectoryProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullの完全修飾名が含まれている必要があります。

カスタム ポリシー スターター パック Microsoft Entra 技術プロファイルの後には、AAD-Common 技術プロファイルが含まれます。 プロトコルは AAD-Common 技術プロファイルで構成されているため、Microsoft Entra 技術プロファイルではプロトコルは指定されません。

  • AAD-UserReadUsingAlternativeSecurityIdAAD-UserReadUsingAlternativeSecurityId-NoError - ディレクトリ内のソーシャル アカウントを検索します。
  • AAD-UserWriteUsingAlternativeSecurityId - 新しいソーシャル アカウントを作成します。
  • AAD-UserReadUsingEmailAddress - ディレクトリ内のローカル アカウントを検索します。
  • AAD-UserWriteUsingLogonEmail - 新しいローカル アカウントを作成します。
  • AAD-UserWritePasswordUsingObjectId - ローカル アカウントのパスワードを更新します。
  • AAD-UserWriteProfileUsingObjectId - ローカル アカウントまたはソーシャル アカウントのユーザー プロファイルを更新します。
  • AAD-UserReadUsingObjectId - ローカル またはソーシャル アカウントのユーザー プロファイルを読み取る。
  • AAD-UserWritePhoneNumberUsingObjectId - ローカルまたはソーシャル アカウントの MFA 電話番号を書き込みます

AAD-Common 技術プロファイルの例を次に示します。

<TechnicalProfile Id="AAD-Common">
  <DisplayName>Azure Active Directory</DisplayName>
  <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.AzureActiveDirectoryProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />

  <CryptographicKeys>
    <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
  </CryptographicKeys>

  <!-- We need this here to suppress the SelfAsserted provider from invoking SSO on validation profiles. -->
  <IncludeInSso>false</IncludeInSso>
  <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
</TechnicalProfile>

インプットクレーム

InputClaims 要素には要求が含まれています。これは、ディレクトリ内のアカウントを検索したり、新しいアカウントを作成したりするために使用されます。 すべての Microsoft Entra 技術プロファイルの入力要求コレクションには、InputClaim 要素が 1 つだけ必要です。 ポリシーで定義されている要求の名前を、Microsoft Entra ID で定義されている名前にマップすることが必要な場合があります。

既存のユーザー アカウントの読み取り、更新、または削除を行うために、入力要求は Microsoft Entra ディレクトリ内のアカウントを一意に識別するキーです。 たとえば、 objectIduserPrincipalNamesignInNames.emailAddresssignInNames.userNamealternativeSecurityId などです。

新しいユーザー アカウントを作成するには、入力要求は、ローカル アカウントまたはフェデレーション アカウントを一意に識別するキーです。 たとえば、ローカル アカウント: signInNames.emailAddresssignInNames.userName などです。 フェデレーション アカウントの場合: alternativeSecurityId

InputClaimsTransformations 要素には、入力要求の変更または新しい要求の生成に使用される入力要求変換要素のコレクションを含めることができます。

出力クレーム

OutputClaims 要素には、Microsoft Entra 技術プロファイルによって返される要求の一覧が含まれています。 ポリシーで定義されている要求の名前を、Microsoft Entra ID で定義されている名前にマップすることが必要な場合があります。 DefaultValue属性を設定している限り、Microsoft Entra ID によって返されない要求を含めることもできます。

OutputClaimsTransformations 要素には、出力要求を修正したり新しい要求を生成するために使用される、OutputClaimsTransformation 要素のコレクションが含まれている場合があります。

たとえば、 AAD-UserWriteUsingLogonEmail 技術プロファイルはローカル アカウントを作成し、次の要求を返します。

  • objectId(新しいアカウントの識別子)
  • newUser。ユーザーが新しいかどうかを示します。
  • authenticationSource。認証を 〗に設定します。 localAccountAuthentication
  • userPrincipalName(新しいアカウントのユーザー プリンシパル名)
  • signInNames.emailAddress。これは、 電子メール 入力要求に似たアカウント サインイン名です
<OutputClaims>
  <OutputClaim ClaimTypeReferenceId="objectId" />
  <OutputClaim ClaimTypeReferenceId="newUser" PartnerClaimType="newClaimsPrincipalCreated" />
  <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="localAccountAuthentication" />
  <OutputClaim ClaimTypeReferenceId="userPrincipalName" />
  <OutputClaim ClaimTypeReferenceId="signInNames.emailAddress" />
</OutputClaims>

永続化クレーム

PersistedClaims 要素には、ポリシーの ClaimsSchema セクションで既に定義されている要求の種類と Microsoft Entra 属性名の間で可能なマッピング情報と共に、Microsoft Entra ID によって永続化する必要があるすべての値が含まれています。

新しいローカル アカウント を作成する AAD-UserWriteUsingLogonEmail 技術プロファイルでは、次の要求が保持されます。

  <PersistedClaims>
    <!-- Required claims -->
    <PersistedClaim ClaimTypeReferenceId="email" PartnerClaimType="signInNames.emailAddress" />
    <PersistedClaim ClaimTypeReferenceId="newPassword" PartnerClaimType="password"/>
    <PersistedClaim ClaimTypeReferenceId="displayName" DefaultValue="unknown" />
    <PersistedClaim ClaimTypeReferenceId="passwordPolicies" DefaultValue="DisablePasswordExpiration" />

    <!-- Optional claims. -->
    <PersistedClaim ClaimTypeReferenceId="givenName" />
    <PersistedClaim ClaimTypeReferenceId="surname" />
  </PersistedClaims>

要求の名前は、Microsoft Entra 属性名を含む PartnerClaimType 属性が指定されていない限り、Microsoft Entra 属性の名前です。

操作の要件

  • すべての Microsoft Entra 技術プロファイルのクレーム バッグには 、InputClaim 要素が 1 つだけ必要です。
  • ユーザー プロファイル属性に関する記事では、入力要求、出力要求、および永続化された要求で使用できる、サポートされている Azure AD B2C ユーザー プロファイル属性について説明します。
  • 操作が Write または DeleteClaimsの場合は、 PersistedClaims 要素にも含まれている必要があります。
  • userPrincipalName 要求の値は、user@tenant.onmicrosoft.comの形式である必要があります。
  • displayName 要求は必須であり、空の文字列にすることはできません。

Microsoft Entra の技術プロファイル操作

お読みください

読み取り操作は、1 つのユーザー アカウントに関するデータを読み取ります。 次の技術プロファイルは、ユーザーの objectId を使用してユーザー アカウントに関するデータを読み取ります。

<TechnicalProfile Id="AAD-UserReadUsingObjectId">
  <Metadata>
    <Item Key="Operation">Read</Item>
    <Item Key="RaiseErrorIfClaimsPrincipalDoesNotExist">true</Item>
  </Metadata>
  <IncludeInSso>false</IncludeInSso>
  <InputClaims>
    <InputClaim ClaimTypeReferenceId="objectId" Required="true" />
  </InputClaims>
  <OutputClaims>

    <!-- Required claims -->
    <OutputClaim ClaimTypeReferenceId="strongAuthenticationPhoneNumber" />

    <!-- Optional claims -->
    <OutputClaim ClaimTypeReferenceId="signInNames.emailAddress" />
    <OutputClaim ClaimTypeReferenceId="displayName" />
    <OutputClaim ClaimTypeReferenceId="otherMails" />
    <OutputClaim ClaimTypeReferenceId="givenName" />
    <OutputClaim ClaimTypeReferenceId="surname" />
  </OutputClaims>
  <IncludeTechnicalProfile ReferenceId="AAD-Common" />
</TechnicalProfile>

書く

書き込み操作では、1 つのユーザー アカウントを作成または更新します。 次の技術プロファイルでは、新しいソーシャル アカウントが作成されます。

<TechnicalProfile Id="AAD-UserWriteUsingAlternativeSecurityId">
  <Metadata>
    <Item Key="Operation">Write</Item>
    <Item Key="RaiseErrorIfClaimsPrincipalAlreadyExists">true</Item>
    <Item Key="UserMessageIfClaimsPrincipalAlreadyExists">You are already registered, please press the back button and sign in instead.</Item>
  </Metadata>
  <IncludeInSso>false</IncludeInSso>
  <InputClaimsTransformations>
    <InputClaimsTransformation ReferenceId="CreateOtherMailsFromEmail" />
  </InputClaimsTransformations>
  <InputClaims>
    <InputClaim ClaimTypeReferenceId="AlternativeSecurityId" PartnerClaimType="alternativeSecurityId" Required="true" />
  </InputClaims>
  <PersistedClaims>
    <!-- Required claims -->
    <PersistedClaim ClaimTypeReferenceId="alternativeSecurityId" />
    <PersistedClaim ClaimTypeReferenceId="userPrincipalName" />
    <PersistedClaim ClaimTypeReferenceId="mailNickName" DefaultValue="unknown" />
    <PersistedClaim ClaimTypeReferenceId="displayName" DefaultValue="unknown" />

    <!-- Optional claims -->
    <PersistedClaim ClaimTypeReferenceId="otherMails" />
    <PersistedClaim ClaimTypeReferenceId="givenName" />
    <PersistedClaim ClaimTypeReferenceId="surname" />
  </PersistedClaims>
  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="objectId" />
    <OutputClaim ClaimTypeReferenceId="newUser" PartnerClaimType="newClaimsPrincipalCreated" />
    <OutputClaim ClaimTypeReferenceId="otherMails" />
  </OutputClaims>
  <IncludeTechnicalProfile ReferenceId="AAD-Common" />
  <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" />
</TechnicalProfile>

削除クレーム

DeleteClaims 操作は、指定されたクレームの一覧から情報をクリアします。 次の技術プロファイルは、要求を削除します。

<TechnicalProfile Id="AAD-DeleteClaimsUsingObjectId">
  <Metadata>
    <Item Key="Operation">DeleteClaims</Item>
  </Metadata>
  <InputClaims>
    <InputClaim ClaimTypeReferenceId="objectId" Required="true" />
  </InputClaims>
  <PersistedClaims>
    <PersistedClaim ClaimTypeReferenceId="objectId" />
    <PersistedClaim ClaimTypeReferenceId="Verified.strongAuthenticationPhoneNumber" PartnerClaimType="strongAuthenticationPhoneNumber" />
  </PersistedClaims>
  <OutputClaims />
  <IncludeTechnicalProfile ReferenceId="AAD-Common" />
</TechnicalProfile>

DeleteClaimsPrincipal さん

DeleteClaimsPrincipal 操作は、ディレクトリから 1 つのユーザー アカウントを削除します。 次の技術プロファイルは、ユーザー プリンシパル名を使用してディレクトリからユーザー アカウントを削除します。

<TechnicalProfile Id="AAD-DeleteUserUsingObjectId">
  <Metadata>
    <Item Key="Operation">DeleteClaimsPrincipal</Item>
  </Metadata>
  <InputClaims>
    <InputClaim ClaimTypeReferenceId="objectId" Required="true" />
  </InputClaims>
  <OutputClaims/>
  <IncludeTechnicalProfile ReferenceId="AAD-Common" />
</TechnicalProfile>

次の技術プロファイルは、 alternativeSecurityId を使用してソーシャル ユーザー アカウントを削除します。

<TechnicalProfile Id="AAD-DeleteUserUsingAlternativeSecurityId">
  <Metadata>
    <Item Key="Operation">DeleteClaimsPrincipal</Item>
  </Metadata>
  <InputClaims>
    <InputClaim ClaimTypeReferenceId="alternativeSecurityId" Required="true" />
  </InputClaims>
  <OutputClaims/>
  <IncludeTechnicalProfile ReferenceId="AAD-Common" />
</TechnicalProfile>

メタデータ

特性 必須 説明
オペレーション イエス 実行する操作。 指定できる値: ReadWriteDeleteClaims、または DeleteClaimsPrincipal
RaiseErrorIfClaimsPrincipalDoesNotExist (英語) いいえ ユーザー オブジェクトがディレクトリに存在しない場合は、エラーを発生させます。 指定できる値: true または false
RaiseErrorIfClaimsPrincipalAlreadyExists いいえ ユーザー オブジェクトが既に存在する場合は、エラーを発生させます。 指定できる値: true または false。 このメタデータは、書き込み操作にのみ適用されます。
アプリケーションオブジェクトID いいえ 拡張属性のアプリケーション オブジェクト識別子。 値: アプリケーションの ObjectId。 詳細については、「 カスタム属性の使用」を参照してください。
ClientId いいえ テナントにサード パーティとしてアクセスするためのクライアント識別子。 詳細については、「カスタム プロファイル編集ポリシーでカスタム属性を使用する」を参照してください。
IncludeClaimResolvingInClaimsHandling いいえ 入力要求と出力要求の場合、 要求解決 を技術プロファイルに含めるかどうかを指定します。 指定できる値: true または false (既定値)。 技術プロファイルでクレーム リゾルバーを使用する場合は、これを trueに設定します。

UI 要素

次の設定を使用して、エラー発生時に表示されるエラー メッセージを構成できます。 メタデータは、 セルフアサート 技術プロファイルで構成する必要があります。 エラー メッセージは、ローカライズできます。

特性 必須 説明
UserMessageIfClaimsPrincipalAlreadyExists (英語) いいえ エラーが発生する場合 (RaiseErrorIfClaimsPrincipalAlreadyExists 属性の説明を参照)、ユーザー オブジェクトが既に存在する場合にユーザーに表示するメッセージを指定します。
UserMessageIfClaimsPrincipalDoesNotExist (英語) いいえ エラーが発生する場合 (RaiseErrorIfClaimsPrincipalDoesNotExist 属性の説明を参照)、ユーザー オブジェクトが存在しない場合にユーザーに表示するメッセージを指定します。

次のステップ

Microsoft Entra 技術プロファイルの使用例については、次の記事を参照してください。