Ad Code

Responsive Advertisement

Ticker

6/recent/ticker-posts

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


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


  1. Enable Windows authentication
  2. Disable anonymous authentication
  3. Add <identity impersonate="true"> in web.config


 <system.web>
    ...
    <authentication mode="Windows"/>
    <identity impersonate="true"/>
    ...
 </system.web>