简体   繁体   中英

Azure B2C custom policy conditional OrchestrationStep

I am trying to introduce new Orchestration Step based on the value of my custom attribute. My requirement is I want to execute the a orchestration step only if the value of myattribute(boolean attribute) is set to true. The value of myattribute is either set to true or false. I am doing something like this.

<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
  <Value>False</Value>
  <Value>extension_myattribute</Value>
  <Action>SkipThisOrchestrationStep</Action>
</Precondition>

But this step is not skipped irrespective of the value of myattribute. I have added the myattribute as part of the OutPutClaims of AAD-UserReadUsingObjectId. I am able see the value of extension_myattribute in the C#.

Any pointers to examples where value is compared will help me a lot.

What you try do do should work, at least there are very similar examples in the starter pack.

https://github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/blob/f376b431dc0c7353faf52632d3d3f735ad5978a1/scenarios/source/aadb2c-ief-terms-of-use/SignUpOrSigninToUDateTime.xml

    <!-- Check if the user has selected to sign in using one of the social providers -->
    <OrchestrationStep Order="2" Type="ClaimsExchange">
      <Preconditions>
        <Precondition Type="ClaimEquals" ExecuteActionsIf="false">
          <Value>authenticationSource</Value>
          <Value>socialIdpAuthentication</Value>
          <Action>SkipThisOrchestrationStep</Action>
        </Precondition>
      </Preconditions>
      <ClaimsExchanges>
        <ClaimsExchange Id="FacebookExchange" TechnicalProfileReferenceId="Facebook-OAUTH" />
        <ClaimsExchange Id="SignUpWithLogonEmailExchange" TechnicalProfileReferenceId="SelfAsserted-Input-ToU-LocalAccountSignUp" />
      </ClaimsExchanges>
    </OrchestrationStep>

The xsd also explicitly mentions "true" and "false"

<xs:attribute use="required" name="ExecuteActionsIf" type="xs:boolean" >
  <xs:annotation>
    <xs:documentation>
      Specifies if the actions in this precondition should be performed if the test is true or false.
    </xs:documentation>
  </xs:annotation>
</xs:attribute>

Maybe your claim is not actually set yet? Or are you mixing attrributes and claims?

For a ClaimEquals precondition, the first <Value /> must be set to the claim type and the second <Value /> must be set to the claim value:

<Precondition Type="ClaimEquals" ExecuteActionsIf="true">
  <Value>extension_myattribute</Value>
  <Value>False</Value>
  <Action>SkipThisOrchestrationStep</Action>
</Precondition>

For a boolean claim, the possible values are "True" and "False".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM