string user = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
Enable Windows authentication
Disable anonymous authentication
- Add
<identity impersonate="true"> in web.config
<system.web>
...
<authentication mode="Windows"/>
<identity impersonate="true"/>
...
</system.web>