-1
 Response.Write("Request.LogonUserIdentity.Name:" +Request.LogonUserIdentity.Name);
 Response.Write("<br/>");            
 Response.Write("WindowsIdentity.GetCurrent().Name:" + WindowsIdentity.GetCurrent().Name);
 Response.Write("<br/>");

如上所述,如果我使用匿名凭据,它将是:

Request.LogonUserIdentity.Name:NT AUTHORITY\IUSR

WindowsIdentity.GetCurrent().Name:IIS APPPOOL\TestSite

但在模仿者之后,LoginUserIdentity将是一样的

Request.LogonUserIdentity.Name:NT AUTHORITY\IUSR

WindowsIdentity.GetCurrent().Name:模仿者身份

MSDN

LogonUserIdentity 属性向 Microsoft Internet Information Services (IIS) 公开当前连接用户的 WindowsIdentity 对象的属性和方法。

为什么loginUserIdentity总是使用匿名身份?

4

1 回答 1

0

You misunderstand authentication and impersonation,

Property Value

Type: System.Security.Principal.WindowsIdentity
A WindowsIdentity object for the current Microsoft Internet Information Services (IIS) authentication settings.

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

于 2012-06-28T02:42:00.123 回答