j-petty
j-petty

Reputation: 3026

How to populate Display Name with Email using B2C custom user flow

I'm implementing a local user B2C custom user flow policy based on Microsoft's guide.

My custom signup/signin policy is working but I want to modify it so that the Display Name field in B2C is automatically populated with the user's email address.

Currently I've disabled removed the Display Name claim from the signup form, meaning it get's populated with "unknown".

I'm using the provided samples as the basis of my policy so if someone can provide an example of how to modify these to support automatically populating the Display Name with the users email that would be perfect.

Upvotes: 3

Views: 1483

Answers (1)

Scott McNeany
Scott McNeany

Reputation: 572

Sounds like you already removed it as an Output Claim from the LocalAccountSignUpWithLogonEmail.

In that same step, you should be able to add an OutputClaimsTransformation with TransformationMethod="CopyClaim", the input being the "email" and the output being the "displayName".

The claims transformation will look like this:

<ClaimsTransformation Id="CopyEmailAddressToDisplayName" TransformationMethod="CopyClaim">
    <InputClaims>
        <InputClaim ClaimTypeReferenceId="email" TransformationClaimType="inputClaim"/>
    </InputClaims>
    <OutputClaims>
        <OutputClaim ClaimTypeReferenceId="displayName" TransformationClaimType="outputClaim"/>
    </OutputClaims>
</ClaimsTransformation>

and to call it from the technical profile, add this section right below the output claims.

<OutputClaimsTransformations>
    <OutputClaimsTransformation ReferenceId="CopyEmailAddressToDisplayName" />
</OutputClaimsTransformations>

Reference: https://learn.microsoft.com/en-us/azure/active-directory-b2c/general-transformations

NOTE: If you're going to change these, I recommend copying the technical profile to the TrustFrameworkExtensions file to avoid confusion between what existed in the base and what you customized.

Upvotes: 4

Related Questions