User.Identity.Name is returning the user used for Connect As in Windows 2000 SP4
This was a very informative case I handled recently. I had to research a lot before I came to a conclusion. I hope this information is useful J
Background
==========
My customer is using Windows Server 2000 SP4 and he has created a website that has its home directory mapped to a network directory. He has provided his domain user's credentials in the *Connect As* button (under the Network Directory Security Credentials).
He has created an asp.net web application that uses Page.User.Identity.Name and is trying to use the logged in user’s identity. Now when this application runs, the Identity that is received is that of the *Connect As* and not of the expected authenticated user (He is using integrated authentication in IIS).
What was happening??
=================
It looks like the behavior that we are seeing is an expected behavior in Windows 2000. The user information of a web request would be changed to the UNC "connect as" user when the web application is accessed by IIS via a Network share in Windows 2000. This overrides the impersonated user. This also affects User.Identity.Name and the ServerVariables.
How to resolve the issue
=====================
To resolve this issue, follow one of the following work-arounds,
1) Use IIS6 (Windows 2003). IIS6 has an option to access remote shares using
the credentials of the authenticated user rather than the "connect as" user.
2) Copy the content locally to the IIS server.