Recently I configured the identity management service Azure AD B2C to handle the Sign Up and Sign In for a Dynamics 365 Portal. When accessed, the Portal will immediately send the Portal User to Azure AD B2C, allowing them to either Sign In with their existing account details or Sign Up by entering their details.
Once they have signed up, a Contact record will be created in Dynamics 365 with their details and a related ‘External Identities’ record will also be created. This will contain both the User’s Id from Azure AD B2C and a reference to the B2C Tenant.
During testing, we performed a data clean-up which removed some Contacts and External Identities, which meant that those Portal Users could no longer log in. To fix this I had to recreate the link between the Contact and the B2C User manually.
The first step for this was to log into the B2C Tenant in Azure and find the User’s Id. I then needed the B2C tenant reference which I could find using the issuer link of the Sign Up Sign In Custom Policy, as I was using Custom Policies in this instance. If I hadn’t been using Custom Policies, the same thing could be found under the User Flow. Once I had these, I was able to re-create the ‘External Identity’ record and relate them to the Contact.
Once this was done, we needed to navigate back to the Contact and select the ‘Portal Contact’ Form. Here we needed to set the ‘Username’ field as anything we wanted (you can use the username on the External Identity) and then ensured Enable Login is ticked in the Local Identity Section of the Web Authentication Tab.
The last thing we had to do was run the Workflow ‘Reset Security Stamp’. After this, the User was able to access the Portal again.