Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the name of the current Windows user returning "IIS APPPOOL/Sitename"

Tags:

asp.net

iis-6

I can't figure this out for the life of me. I'm trying to get the name of the current user logged onto Windows using the following line:

string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();

When I run this line after publishing and opening it through IIS, it gives me a name of "IIS APPPOOL/SiteName". However, when I run this through the Visual Studio 2013 debugger, the correct name appears.

like image 505
LOL. NO. Avatar asked May 13 '15 22:05

LOL. NO.


People also ask

What is IIS AppPool user?

An application pool identity allows you to run an application pool under a unique account without having to create and manage domain or local accounts. The name of the application pool account corresponds to the name of the application pool.

How do I find my Windows username in asp net?

If your website is set up to run with Anonymous Access only, then you will not get the user. You need to change the settings to allow Integrated Windows Authentication to retrieve the user name. In the page, you can use Page.User.Identity.Name .

What is the name of default application pool in IIS?

Creating Application Pools This is IIS's isolation functionality and is where you can recycle, change process identity security, and view health and diagnostics information. By default, IIS 7.0 provides you with a single application pool called DefaultAppPool.


1 Answers

I've fiddled around with the config, IIS settings, and the string...but I think this line is what I needed to use:

string user = System.Web.HttpContext.Current.User.Identity.Name;

Seems to be returning a domain/username which I can use instead. Looks like an alternative solution.

like image 86
LOL. NO. Avatar answered Oct 27 '22 00:10

LOL. NO.