We actually came up to a solution but offcourse an unsupported one but works nicely.
- In azure B2C have a seperate signin flow and register flow
- In Dynamics CRM create 2 OpenIdconnect providers, one connected to the register and one to the signup. Create at least:
Authentication/OpenIdConnect/AAD-B2C_2/Authority
Authentication/OpenIdConnect/AAD-B2C_2/ClientId
Authentication/OpenIdConnect/AAD-B2C_2/DefaultPolicyId
Authentication/OpenIdConnect/AAD-B2C_2/RedirectUri
Authentication/OpenIdConnect/AAD-B2C_2/Caption = Register
- Set Authentication/Registration/OpenRegistrationEnabled to false
Extend Authentication/OpenIdConnect/AAD-B2C_1/ValidIssuers with the new register flow issuer
Now you basically should have 2 buttons to login/register. one puts you to the register flow, other to the Signin flow which you want to use.
In the end set Authentication/Registration/LoginButtonAuthenticationType to the signin flow issuer url so when pressing Signin this goes to signinflow.
When you use the portal page /Account/Login/Register?invitationCode=xxxxxxxxxxx you will see those buttons but the invite is not checked against CRM.
We have hidden the buttons through javascript in the footer page, added code to basically do the check which is done on the normal register page and if succesfull run the action of the register button.
AddInFooterWebTemplate.zip
Finally: in CRM an external identitywill be registerd at the contact for the registerflow, for signin this needs to be the signin url, have a realtime workflow on External Identity which copy's the record into the signin record. The contact is not attached at creation but put in directly after creation, so set workflow to on created and field change "contact", check Like:
If External Identity:Identity Provider contains [b2c_1_register] AND External Identity:Contact contains data, then: Create record with same values for contact and username but the idenity provider the Signin issuer.
If you invite someone point the link to portal/Account/Login/Register?invitationCode=xxxxxxxx and they will end up in Register flow.
It took some time but it works.
Credits for the great supporter on this case.