简体   繁体   中英

MVC Core: Windows Authentication

How can I get the DOMAIN/username in MVC Core once published? I have Identity installed, and realize that for logged-in users

HttpContext.User.Identity.Name

would work but prefer that all users do not need to be logged in. Rather, I would like to use the client box domain/username.

In a local environment, I can do this with:

System.Security.Principal.WindowsIdentity.GetCurrent().Name;

but this doesn't work once published. Once published it renders "IIS APPPOOL/AppName". Is this the expected functionality? If not, how do I fix this?

Most of the information I can find online relates to modifying the web.config file...

The closest I could find is Windows Authentication with asp.net core

but I'm not sure how I would implement in the controller once I follow that

After a decent amount of searching, it looks like it isn't easily feasible as Camilo Terevinto stated. I'm going to have to implement Identity for all users.

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