Article ID: 306359 - View products that this article applies to.
This article was previously published under Q306359
If you try to access the Request.ServerVariables("LOGON_USER") variable in ASP.NET, an empty string is returned.
NOTE: If you are using Microsoft Visual C# .NET, the following syntax accesses this variable:
This problem occurs because the authentication-related variables in the ServerVariables collection are not populated if you use Anonymous Access security to access the .aspx page. This problem can also occur if you give the Anonymous user access in the <authorization> section of the Web.config file.
To populate the LOGON_USER variable when you use any authentication mode other than None, you can deny access to the Anonymous user in the <authorization> section of the Web.config file. To deny access to the Anonymous user in the <authorization> section, follow these steps:
ASP.NET provides new authentication modes and authorization schemes, which you can configure in the .config files. For this reason, modifying the authentication modes in IIS alone may not always yield the desired results. Therefore, you must also consider the security settings in the .config files.
NOTE: When you enable Anonymous authentication in conjunction with Windows authentication or if you grant access to the Anonymous user in the <authorization> section while you are using any authentication mode other than None, other server variables such as AUTH_USER and REMOTE_USER (as well as the HttpContext.Current.User.Identity.Name property) also return an empty string. You can use the any of the above-mentioned resolutions to populate these variables.
In ASP.NET, you can also use the IsAuthenticated property of the Request object to determine whether the Anonymous Access security is being used. IsAuthenticated returns "false" if Anonymous Access is turned on and returns "true" if you use any other means of authentication such as Forms, Passport, Integrated (NT Challenge/Response), or Basic.
For more information about security in ASP.NET, refer to the following MSDN Web site:
ASP.NET Web Application SecurityFor additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
(https://support.microsoft.com/kb/306590/EN-US/ )INFO: ASP.NET Security Overview
(https://support.microsoft.com/kb/222028/EN-US/ )Setting Up Digest Authentication for Use with Internet Information Services 5.0
(https://support.microsoft.com/kb/188717/EN-US/ )PRB: Request.ServerVariables("LOGON_USER") Returns Empty String
Article ID: 306359 - Last Review: December 3, 2007 - Revision: 3.8