views:

448

answers:

3

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

+2  A: 

In the web.config on Server2, do you have: authentication mode="Windows"?

consultutah
Yes, both web.configs have this.
AJ
Few more things to check: 1. Verify that "Enable Anonymous Access" is false on the virtual directory and any internal directories. 2. Any other web.configs in internal directories?
consultutah
I found a few virtual directories on Server2 that had Anonymous Access enabled, and corrected that issue. I also checked any web.config files in internal directories, and all were set to "Windows" with no other overriding factors. The problem persists. Server2's web service is sharing an Application Pool with other websites that allow anonymous access. Could this be part of the problem?
AJ
+1 for your ongoing assistance.
AJ
I changed the Application Pool setup so that it is identical to Server1, and it's still happening, so I guess that's out too.
AJ
+2  A: 

Since IUSR_* is the default anonymous user and anonymous access is disabled in IIS, it sounds like anonymous access is enabled in your web.config. Please make sure the authorization section in your web.config looks similar to this:

<authorization>
    <deny users="?" /> <!-- Reject anonymous users -->
    <allow users="*" /> <!-- Accept all other users (or replace * with a list of users) -->
</authorization>
Heinzi
Neither web.config had an `authorization` section. I added exactly what you posted to both. Now, Server1 behaves the same (correctly), and Server2 throws a 401.2 Unauthorized exception. I'm going to update the original post with this information.
AJ
Thanks for the update. In that case, *Windows authentication* fails for some reason. Since Server2 cannot fall back to anonymous access anymore, it throws an error. Is your client configured correctly? Have a look at this document: http://msdn.microsoft.com/en-us/library/bfazk0tb.aspx
Heinzi
Yes, the client is configured correctly. Actually, these are "test" servers, so I'm using the web services test form on both servers. But the actual client is impersonating a domain user and the same results occur.
AJ
+1 for your ongoing assistance.
AJ
Thanks. :-) Hmm... the clients and server2 are in the same domain, right?
Heinzi
That's correct. All clients, server1, and server2 are in the same domain.
AJ
Quite a challenging problem; and I think it does not have anything to do with the fact that you're running a SOAP web service (which can be tested easily: just add a "simple" aspx page to your web project). One more try: Does IE recognize server2 as "local intranet zone"? (Should be visible in the right-hand corner of the status bar.)
Heinzi
Yea, both servers show up as "Local Intranet." I think at this point I'm going to try and wipe the entire IIS configuration on Server2 and start over. Thanks again for your help.
AJ
You're welcome; good luck! Let us know how it turned out...
Heinzi
A: 

Unfortunately, I never got to the root of this problem. We ended up moving to new servers and with a fresh IIS configuration on both, this problem went away. I suspect that it may have had something to do with the manner in which the NICs were set up on the server, as it was a virtual server with multiple NICs. But I still don't know for sure. Thanks again to Heinzi and consultutah for their help.

AJ