NotFound
NotFound

Reputation: 6102

Obtain user from Azure Web App using AD authentication

I have an ASP.NET-CORE Azure Web App running using AD authentication (all setup in Azure using the Authentication/Authorization blade). It seems to be functioning as intended as users are requested to login when accessing the site. How can I obtain the current using making the call to the App Service?

I was assuming the current user was obtainable through User?.Identity.Name as authentication, but that yields a null.

Upvotes: 0

Views: 58

Answers (1)

NotFound
NotFound

Reputation: 6102

The username can be found in headers under the key X-MS-CLIENT-PRINCIPAL-NAME. To obtain it the following piece of code could be used Request.Headers["X-MS-CLIENT-PRINCIPAL-NAME"];

Upvotes: 1

Related Questions