แก้ไข

แชร์ผ่าน


BuildingBlocks

Note

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. If you've not done so, learn about custom policy starter pack in Get started with custom policies in Active Directory B2C.

The BuildingBlocks element is added inside the TrustFrameworkPolicy element.

<TrustFrameworkPolicy
  xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="https://www.w3.org/2001/XMLSchema"
  xmlns="http://schemas.microsoft.com/online/cpim/schemas/2013/06"
  PolicySchemaVersion="0.3.0.0"
  TenantId="mytenant.onmicrosoft.com"
  PolicyId="B2C_1A_TrustFrameworkBase"
  PublicPolicyUri="http://mytenant.onmicrosoft.com/B2C_1A_TrustFrameworkBase">

  <BuildingBlocks>
    <ClaimsSchema>
      ...
    </ClaimsSchema>
    <Predicates>
    ...
    </Predicates>
    <PredicateValidations>
    ...
    </PredicateValidations>
    <ClaimsTransformations>
      ...
    </ClaimsTransformations>
    <ContentDefinitions>
      ...
    </ContentDefinitions>
    <Localization>
      ...
    </Localization>
    <DisplayControls>
      ...
    </DisplayControls>
 </BuildingBlocks>

The BuildingBlocks element contains the following elements that must be specified in the order defined:

  • ClaimsSchema - Defines the claim types that can be referenced as part of the policy. The claims schema is the place where you declare your claim types. A claim type is similar to a variable in many programmatic languages. You can use the claim type to collect data from the user of your application, receive claims from social identity providers, send and receive data from a custom REST API, or store any internal data used by your custom policy.

  • Predicates and PredicateValidationsInput - Enables you to perform a validation process to ensure that only properly formed data is entered into a claim.

  • ClaimsTransformations - Contains a list of claims transformations that can be used in your policy. A claims transformation converts one claim into another. In the claims transformation, you specify a transform method, such as:

    • Changing the case of a string claim to the one specified. For example, changing a string from lowercase to uppercase.
    • Comparing two claims and returning a claim with true indicating that the claims match, otherwise false.
    • Creating a string claim from the provided parameter in the policy.
    • Creating a random string using the random number generator.
    • Formatting a claim according to the provided format string. This transformation uses the C# String.Format method.
  • InputValidation - This element allows you to perform boolean aggregations that are similar to and and or.

  • ContentDefinitions - Contains URLs for HTML5 templates to use in your user journey. In a custom policy, a content definition defines the HTML5 page URI that's used for a specified step in the user journey. For example, the sign-in or sign-up, password reset, or error pages. You can modify the look and feel by overriding the LoadUri for the HTML5 file. Or you can create new content definitions according to your needs. This element may contain a localized resources reference using a localization ID.

  • Localization - Allows you to support multiple languages. The localization support in policies allows you set up the list of supported languages in a policy and pick a default language. Language-specific strings and collections are also supported.

  • DisplayControls - Defines the controls to be displayed on a page. Display controls have special functionality and interact with back-end validation technical profiles.