How to check user exists in AD B2C, using custom policy?

AB 156 Reputation points
2020-01-23T14:49:22.04+00:00

I have a signup flow and it is working fine and it is multi-step:

  1. Contact details
  2. Verification
  3. Password

And now the flow is, after completing all steps a new user will get created, if the user name already exists then in the last step I'm getting an error message that the user already exists. Now I need to change this flow. After entering the contact details(email), I want to check whether this user exists or not. If it exists then I need to show the error message that shows in the last step in the first step itself and block the journey from moving to the next step.

To achieve this, what I did is:

Created a TP that reads the user details using email and put that as a validation technical profile for the first step:

alt text
And added alt text to alt text

Following is the validation profile section:

alt text

But it is not working as expected, I tried with an existing user after clicking next on the first step it moves the verification step without any error.

Microsoft Entra External ID
Microsoft Entra External ID
A modern identity solution for securing access to customer, citizen and partner-facing apps and services. It is the converged platform of Azure AD External Identities B2B and B2C. Replaces Azure Active Directory External Identities.
2,639 questions
{count} votes

Accepted answer
  1. AB 156 Reputation points
    2020-01-31T10:06:42.043+00:00

    I find solution in another way as follows:

    After a Read Operation, the objectId claim is populated only if the user already exists. I have put Read with RaiseErrorIfClaimsPrincipalDoesNotExist = false and then I used ClaimTransformations and ValidationTechnicalProfiles to block the UserJourney if objectId != null. More specifically
    used "UserMessageIfClaimsTransformationStringsAreNotEqual"

    5 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Dyasani, Ranjeeth (NonEmp) 1 Reputation point
    2021-11-25T03:00:16.567+00:00

    I ran into the same issue, where I'm using display control for email verification as part of the sign up process. My good guess is that 'AAD-UserReadUsingEmailAddress' exists for SSPR and would only throw an error if the user doesn't exist. However I was able to resolve this by adding a write step after read, if the user is found with a precondition to see if my objectId claimExists and this will throw an error if the user exists and skips the write step if the user doesn't exist. It's lil hacky but works. Hope this helps!

    152453-image.png