2012-06-27 13 views
0
Response.Write("Request.LogonUserIdentity.Name:" +Request.LogonUserIdentity.Name); 
Response.Write("<br/>");    
Response.Write("WindowsIdentity.GetCurrent().Name:" + WindowsIdentity.GetCurrent().Name); 
Response.Write("<br/>"); 

如上,如果我用匿名證書,這將是:Request.LogonUserIdentity和WindowsIdentity.GetCurrent()

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對象爲方法目前連接的用戶爲 微軟實習生等信息服務(IIS)。

爲什麼loginUserIdentity始終是身份匿名用?

回答

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

相關問題