Search code examples
mysqlasp.netwebformsazure-ad-b2cuserid

How to obtain signed in Azure B2C user’s id when submitting web form data to MySQL database table?


I currently have an ASP.NET web which sends the inputs of each request to MySQL database table. Since I’m using Azure B2C to register and login my users, how can I send the user’s id to the database table? Do I have to add a connection string to reference the Azure B2C database? I can’t find any information on this. If there is an alternate way of distinguishing who is submitting them form, I’m open to accept any ideas. I just need to know who is submitting each form to me.


Solution

  • You can select the User's Object ID to be returned as a claim in the token. You can then read that claim in ASP.Net and pass it along to MySQL.

    See line 34 of this sample app on how to read the objectId.

    application claims

    select claims/attributes