Strange IIS Windows Authentication behavior

asp.netauthenticationiis-6web services

I have an ASP.NET 3.5 web service (old school SOAP, not WCF) running on two servers set up identically in IIS 6.0. The Authentication/Access control is set up as follows:

  • Enable Anonymous Access = False
  • Integrated Windows authentication = True
  • Digest authentication for Windows domain servers = False
  • Basic authentication = False
  • .NET Passport authentication = False

In one of the web methods, I need to get the Identity of the requesting user and validate that it's in a certain Active Directory group. So, the first line of code in the web method is this:

var requestUser = HttpContext.Current.Request.LogonUserIdentity.Name;

For some reason the results are different between the two servers. Server1 works as expected, producing domain\UserId. However, Server2 produces Server2\IUSR_SERVER2. Has anyone experienced this before? I did find this question, but I'm pretty sure it doesn't apply here as client and both servers are all in the same domain.

Additional Info

Based on Heinzi's response, I added the following to the <system.web> section in both web.config files:

<authorization>
    <deny users="?" />
    <allow users="*" />
</authorization>

Now, Server1 behaves the same, as in, it behaves as I want it to. However, Server2 throws a 401.2: Unauthorized error:

Server Error in '/' Application.

Access is denied.
Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.

Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.

Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3053

Best Answer

I was creating a new MVC 4 ASP.NET web application and ran into the exact same error as you (Error 401.2) when I tried to build my project for the first time.

I changed the options in IIS Manager on my development machine to disable anonymous authentication and enable windows authentication, but I was still getting the 401.2 error.

I did a little research and found out that I could change the properties of my project and resolve this error.

Solution Explorer:

  • Select your Project
  • Press F4 to show the Properties Window

Properties Window:

  • Change 'Anonymous Authentication' to 'Disabled'
  • Change 'Windows Authentication' to 'Enabled'

I hope this helps other people if it doesn't solve your specific problem. As long as you have the same settings on your Web Server, it should work as intended.