Response.Write("Request.LogonUserIdentity.Name:" +Request.LogonUserIdentity.Name);
Response.Write("<br/>");
Response.Write("WindowsIdentity.GetCurrent().Name:" + WindowsIdentity.GetCurrent().Name);
Response.Write("<br/>");
as above, if I use anonymous credential, it will be:
Request.LogonUserIdentity.Name:NT AUTHORITY\IUSR
WindowsIdentity.GetCurrent().Name:IIS APPPOOL\TestSite
But after impersonator, LoginUserIdentity will be the same
Request.LogonUserIdentity.Name:NT AUTHORITY\IUSR
WindowsIdentity.GetCurrent().Name:impersonator identity
MSDN said that
The LogonUserIdentity property exposes the properties and methods of
the WindowsIdentity object for the currently connected user to
Microsoft Internet Information Services (IIS).
Why loginUserIdentity is always the identity anonymous used??
You misunderstand authentication and impersonation,
Whether you enable impersonation or not, the logon user remains the same, so Request.LogonUserIdentity should remain the same, which obviously is correct and meet expectation.
The change of WindowsIdentity.GetCurrent is also expected, as that’s just caused by impersonation.
Reference:
http://msdn.microsoft.com/en-us/library/system.web.httprequest.logonuseridentity.aspx
http://msdn.microsoft.com/en-us/library/ms998351.aspx