Search code examples
azure-ad-b2cblazor-server-sideblazor-client-side

AAD B2c primary key


I'm using Blazor webassembly with Azure ADB2C. A typical task is to retrieve only those records for the logged in user. Which field from AzureB2C is the best practice to use as the authorized user's primary key?

I assumed that using the object ID which is a guid and created by Azure ADB2C would be the correct unique field. However I also see examples on the internet using either the user's email and/or user's name.

I plan on using this field as as a unique field in database tables for the user.


Solution

  • Per documentation, Microsoft Graph uses userprincipalname or objectID for queries

    GET /users/{id | userPrincipalName}
    

    You can apply filters to Microsoft Graph calls but generally the objectID is immutable and is the primary identifier that I've seen with enterprise applications/services.