简体   繁体   中英

How to get current Active Directory user in ASP.NET when IIS is running under a service account

I need to get the name and email address of the user currently logged into Active Directory from a website that is using a service account as the application pool identity in IIS. I've tried the following two methods but they return the name of the service account, not the actual user logged into the network (which makes sense).

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

UserPrincipal.Current.EmailAddress

Does anyone know if this is possible?

HttpContext.Current.User.Identity;

should provide the identity of the authenticated user

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