To include the onpremisessamaccountname as a claim in the JWT token for Azure AD, you need to follow these steps:
Create a custom attribute in your Active Directory (AD) schema to store the onpremisessamaccountname. This can be done using the Active Directory Schema snap-in.
Sync the custom attribute to Azure AD using Azure AD Connect.
Create a custom application in Azure AD if you haven't already done so. This can be done using the Azure Portal.
In the application manifest, add the following lines to the "appId" section:
"optionalClaims": { "idToken": [ { "name": "onpremisessamaccountname", "source": null, "essential": false, "additionalProperties": [] } ] }
Save the manifest and wait for the changes to take effect (this may take a few minutes).
In your application code, use the following code to retrieve the onpremisessamaccountname claim from the JWT token:
string onpremisessamaccountname = User.Claims.FirstOrDefault(c => c.Type == "onpremisessamaccountname")?.Value;
This code assumes that you are using the ASP.NET Core Identity framework. If you are using a different framework, you may need to modify the code accordingly.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-02-05 11:00:00 +0000
Seen: 7 times
Last updated: Aug 30 '21
How can a role assignment be added to a managed identity that is assigned to a system in Azure?
How can key vault be utilized to access Azure blob storage in Databricks?
How can Oracle Tables in bulk be transferred to Azure Storage using Azure Data Factory?
What is the reason for the authentication failure in Azure GIT?
What is the process of utilizing Forge API with Azure, S3, or other storage systems?