For my sign up and sign in flow with Azure AD B2C I try to check, if the user already exists in the Azure B2C database with the specific signInName. If he already exists (objectId is not null) he should be redirected to signIn – if the user doesn’t exists already (objectId is null) then he should sign up. This part already worked – so far so good.
Now I added a new ClaimTypes with the name objectIdIsNull
(boolean) and objectIdIsEmpty
(also boolean) and they are set in their ClaimsTransformations. Then I added an additional OutputClaimsTransformation CheckObjectIdValidity
, which sets the ClaimType objectIdIsNullOrEmpty
to true, if the objectId is null or empty:
<!-- Check if objectId is null (User is not in B2C) -->
<ClaimsTransformation Id="CheckObjectIdIsNull" TransformationMethod="CompareClaimToValue">
<InputClaims>
<InputClaim ClaimTypeReferenceId="objectId" TransformationClaimType="inputClaim1" />
</InputClaims>
<InputParameters>
<InputParameter Id="compareTo" DataType="string" Value="Null" />
<InputParameter Id="operator" DataType="string" Value="EQUAL" />
<InputParameter Id="ignoreCase" DataType="string" Value="true" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="objectIdIsNull" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
<!-- Check if objectId is empty (User was invited already) -->
<ClaimsTransformation Id="CheckObjectIdIsEmpty" TransformationMethod="CompareClaimToValue">
<InputClaims>
<InputClaim ClaimTypeReferenceId="objectId" TransformationClaimType="inputClaim1" />
</InputClaims>
<InputParameters>
<InputParameter Id="compareTo" DataType="string" Value="" />
<InputParameter Id="operator" DataType="string" Value="EQUAL" />
<InputParameter Id="ignoreCase" DataType="string" Value="true" />
</InputParameters>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="objectIdIsEmpty" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
<ClaimsTransformation Id="CheckObjectIdValidity" TransformationMethod="OrClaims">
<InputClaims>
<InputClaim ClaimTypeReferenceId="objectIdIsEmpty" TransformationClaimType="inputClaim1"/>
<InputClaim ClaimTypeReferenceId="objectIdIsNull" TransformationClaimType="inputClaim2"/>
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="objectIdIsNullOrEmpty" TransformationClaimType="outputClaim" />
</OutputClaims>
</ClaimsTransformation>
Now the thing is, that when I try to check if the User already exists in the B2C database, the objectId = "Null"
– but when my ClaimsTransformation “CheckObjectIdIsNull
” checks the value – the output objectIdIsNull is false, when it should be true. This is what I get in my applicationInsights:
"Key": "ClaimsTransformation",
"Value": {
"Values": [
{
"Key": "Id",
"Value": "CheckObjectIdIsNull"
},
{
"Key": "InputClaim",
"Value": {
"PolicyClaimType": "objectId",
"Value": "Null"
}
},
{
"Key": "InputParameter",
"Value": {
"Id": "compareTo",
"Value": "Null"
}
},
{
"Key": "InputParameter",
"Value": {
"Id": "operator",
"Value": "EQUAL"
}
},
{
"Key": "InputParameter",
"Value": {
"Id": "ignoreCase",
"Value": "true"
}
},
{
"Key": "Result",
"Value": {
"PolicyClaimType": "objectIdIsNull",
"Value": "False"
}
}
]
}
and the claims after the OrchestrationStep are like this – what am I doing wrong?
"Statebag": {
"Complex-CLMS": {
"signInName": "[email protected]",
"objectId": "Null",
"authenticationSource": "localAccountAuthentication",
"objectIdIsEmpty": "False",
"objectIdIsNull": "False",
"objectIdIsNullOrEmpty": "False"
}
}
I tried a lot but I don’t know what I’m making wrong.