Ways to get Active Directory logon name in ASP.NET page

I’ve recently spent some time to find a best way to get visitors’ Active Directory name in my ASP.NET page. You’ll find a list of techniques.

Note: Some of them may require cookies to be enabled or need Anonymous Access to be disabled in IIS. Also you may need to do string parsing in some cases.

Request.ServerVariables["HTTP_COOKIE"];
Request.ServerVariables["LOGON_USER"]
Request.ServerVariables["REMOTE_USER"];
Request.ServerVariables["UNMAPPED_REMOTE_USER"];
Request.ServerVariables["AUTH_USER"];
System.Security.Principal.WindowsIdentity.GetCurrent().Name;
HttpContext.Current.User.Identity.Name;
HttpContext.Current.Request.LogonUserIdentity.Name

Leave a Reply