Python Forum

Full Version: Flask - IIS Get Windows User Name
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a Flask application (Python version 3.7) running on IIS ( version 10).  I'm trying to get the Windows username value of the User that is browsing the web site. 

I've used
  • getpass.getuser()
  • os.environ.get("USERNAME")

Getting a value back isn't the problem. The value is always this Service Name or Machine Name account name similar to  SERVICEACCT$. Not "domain\joeb" for example. I have tried numerous web.config file settings every which way I can think of with regards to 

<authentication mode="Windows" />
<identity impersonate="true" /> 

As well as fiddling around with the Authentication settings via IIS Manager.  

Enabling ASP.NET Impersonation
Enabling Windows Authentication 
Enabling / Disabling Anonymous Authentication 

I've even set the IIS APPPOOL identity to a user account value ( my own id) and I still get the SERVICEACCT$ value returned from the getpass.getuser() call.

Regardless of what I try in terms of configuration, I always get what I assume is some service account name. I never get a value like "domain\joew". Is the wfastcgi module just incapable of facilitating Impersonation?