HttpContext.Current.User.Principal vs WindowsIdentity.GetCurrent ()

What is the difference in asp.NET with Windows authentication and personification of identity between HttpContext.Current.User.Principal and WindowsIdentity.GetCurrent ()?

+8
iis windows-authentication
source share
1 answer

According to this forum on WindowsIdentity.GetCurrent().Name vs. User.Identity.Name :

  • User.Identity.Name represents the identifier passed from IIS.
  • WindowsIdentity.GetCurrent().Name is the identity under which the thread operates.

Depending on the authentication settings of your application in IIS, they return different values:

 | 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 | 

Legend

  • Where domain \ user will be displayed as:
    • domain \ user for Active Directory
    • computer_name \ username for local account
  • Where NT \ Network Service will be displayed as:
    • NT \ Network Service for Windows Server or ASP.NET
    • computer_name \ ASPNET_WP for Windows XP
+11
source

All Articles