简体   繁体   中英

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 .

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"];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM