How to get user name using Windows authentication in asp.net?
These are the different variables you have access to and their values, depending on the IIS configuration. Scenario 1: Anonymous Authentication in IIS with impersonation off. HttpContext.Current.Request.LogonUserIdentity.Name SERVER1\IUSR_SERVER1 HttpContext.Current.Request.IsAuthenticated False HttpContext.Current.User.Identity.Name – System.Environment.UserName ASPNET Security.Principal.WindowsIdentity.GetCurrent().Name SERVER1\ASPNET Scenario 2: Windows Authentication in IIS, impersonation off. HttpContext.Current.Request.LogonUserIdentity.Name MYDOMAIN\USER1 HttpContext.Current.Request.IsAuthenticated True HttpContext.Current.User.Identity.Name MYDOMAIN\USER1 System.Environment.UserName ASPNET Security.Principal.WindowsIdentity.GetCurrent().Name SERVER1\ASPNET Scenario … Read more