Azure B2C – Check if objectId is null or empty

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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><!-- 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>
</code>
<code><!-- 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> </code>
<!-- 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:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>"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"
}
}
]
}
</code>
<code>"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" } } ] } </code>
"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?

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>"Statebag": {
"Complex-CLMS": {
"signInName": "[email protected]",
"objectId": "Null",
"authenticationSource": "localAccountAuthentication",
"objectIdIsEmpty": "False",
"objectIdIsNull": "False",
"objectIdIsNullOrEmpty": "False"
}
}
</code>
<code>"Statebag": { "Complex-CLMS": { "signInName": "[email protected]", "objectId": "Null", "authenticationSource": "localAccountAuthentication", "objectIdIsEmpty": "False", "objectIdIsNull": "False", "objectIdIsNullOrEmpty": "False" } } </code>
"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.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật