【发布时间】:2011-03-23 07:54:02
【问题描述】:
在启用了 Windows 身份验证和身份模拟的 asp.NET 环境中,HttpContext.Current.User.Principal 和 WindowsIdentity.GetCurrent() 有什么区别?
【问题讨论】:
标签: asp.net iis windows-authentication
在启用了 Windows 身份验证和身份模拟的 asp.NET 环境中,HttpContext.Current.User.Principal 和 WindowsIdentity.GetCurrent() 有什么区别?
【问题讨论】:
标签: asp.net iis windows-authentication
据此论坛WindowsIdentity.GetCurrent().Name vs. User.Identity.Name:
User.Identity.Name表示从 IIS 传递的标识。WindowsIdentity.GetCurrent().Name是线程运行的标识。
根据您应用在 IIS 中的身份验证设置,它们将返回不同的值:
| @987654322@ | @987654323@ | 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 |
传奇:
【讨论】: