2011-03-23 13 views
8

打開Windows身份驗證和身份模擬後,在HttpContext.Current.User.Principal和WindowsIdentity.GetCurrent()之間打開的asp.NET環境中有什麼區別?HttpContext.Current.User.Principal與WindowsIdentity.GetCurrent()

+0

儘管這個問題已經得到解答,但我發現[this](http://forums.asp.net/t/1507047.aspx?WindowsIdentity%20GetCurrent%20Name%20vs%20User%20Identity%20Name)和[此鏈接](http://msdn.microsoft.com/en-us/library/aa302377.aspx)更清楚地回答了它。 – chenz 2014-02-24 03:48:36

回答

11

根據這個論壇上WindowsIdentity.GetCurrent().Name vs. User.Identity.Name

  • User.Identity.Name表示從IIS傳遞的身份。
  • WindowsIdentity.GetCurrent().Name是線程正在運行的標識。

根據在IIS中的應用程序的身份驗證設置,他們將返回不同的值:

| Anonymous | Impersonate | User.Identity.Name | WindowsIndentiy.GetCurrent() | 
|-----------|-------------|--------------------|-------------------------------| 
| Yes  | True  | Empty String  | IUSR_<machineName>   | 
| Yes  | False  | Empty String  | NT Authority\Network Service | 
| No  | True  | domain\user  | domain\user     | 
| No  | False  | domain\user  | NT Authority\Network Service | 

傳說

  • 域\用戶將顯示爲:
      爲Active Directory
    • 域\用戶
    • 計算機名\用戶名本地帳戶
  • NT AUTHORITY \ Network服務將顯示爲:
    • NT AUTHORITY \網絡服務的Windows服務器或ASP.NET
    • 計算機名\的aspnet_wp對於Windows XP
相關問題