Request.LogonUserIdentity和WindowsIdentity.GetCurrent()

时间:2012-06-27 23:19:07

标签: authentication iis identity

 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属性公开了属性和方法   当前连接用户的WindowsIdentity对象   Microsoft Internet信息服务(IIS)。

为什么loginUserIdentity始终是匿名使用的身份?

1 个答案:

答案 0 :(得分:0)

您误解了身份验证和假冒,

Property Value

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

无论是否启用模拟,登录用户都保持不变,因此Request.LogonUserIdentity应保持不变,这显然是正确的并符合预期。

WindowsIdentity.GetCurrent的更改也是预期的,因为这只是假冒造成的。

参考:

http://msdn.microsoft.com/en-us/library/system.web.httprequest.logonuseridentity.aspx

http://msdn.microsoft.com/en-us/library/ms998351.aspx

相关问题