8
打開Windows身份驗證和身份模擬後,在HttpContext.Current.User.Principal和WindowsIdentity.GetCurrent()之間打開的asp.NET環境中有什麼區別?HttpContext.Current.User.Principal與WindowsIdentity.GetCurrent()
打開Windows身份驗證和身份模擬後,在HttpContext.Current.User.Principal和WindowsIdentity.GetCurrent()之間打開的asp.NET環境中有什麼區別?HttpContext.Current.User.Principal與WindowsIdentity.GetCurrent()
根據這個論壇上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 |
傳說:
儘管這個問題已經得到解答,但我發現[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