I am creating B2C users with Social Identity Providers with the help of a Sign-up policy but we have a requirement to add some user attributes (extended properties) to this new user. For example set "AccountId" for the user.
If i add "AccountId" as a Sign-up Attribute and enter some value it works fine, when I check the user properties via Graph API the "AccountId" is correct.
But in this case the "AccountId" should not be editable or visible to the user, I just want the Sign-up policy to add "AccountId" to the user created with for example facebook,as a hidden field on the Sign-up page.
Is it possible, from my ASP.Net MVC application using Azure B2C AD, to pass this value to the Sign-up page and associate it with a Sign up attribute ? Can it be done via parameter (&accountid=1234) or from some OpenId-propperties ?
Azure AD B2C does not currently accept any extra query string parameters that are used to populate a users profile attributes. There is a request for this in the Azure AD B2C UserVoice forum.
You can, however, achieve the same result by implementing it in yourself in the application using the Graph.
For your specific example, you'd need to ensure you're sending the configure your Signup or Signup/Signin policy to send the newUser claim and then use that after authentication to call the Graph and make your necessary updates.
Here's an example of how you can achieve that, assuming you're using ASP.Net as per this SignIn sample or this SignUp/SignIn sample, by leveraging the SecurityTokenValidated notification while setting up your OpenIdConnectAuthenticationOptions like so:
And use the ClientCredentials flow to call out to the Graph API to make an update like so:
Important notes: