How to find out the name of the current user in ASP.NET?

I have an ASP.NET application that runs on machine 1.

When a user accesses this page from machine 2, I want to find out the username under which he or she logged in to machine 2.

I tried to use

  • Request.LogonUserIdentity.Name
  • Page.User.Identity.Name
  • ((WindowsIdentity)HttpContext.Current.User.Identity).Name
  • ((WindowsIdentity)HttpContext.Current.User.Identity).User
  • Request.LogonUserIdentity.User

but that will not work.

Request.LogonUserIdentity.Namereturns NT AUTHORITY\IUSR, Request.LogonUserIdentity.User- S-1-5-17, all the rest are empty strings. NT AUTHORITY\IUSR- This is the user on the computer on which the web application is running, and not on the client machine.

Q web.configI turned off giving myself away with

<authentication mode="Windows"/>
<identity impersonate="false"/>

What can I do to get a username that accesses a web page?

+4
source share
1 answer

IIS Windows (, , ):

enter image description here

:

  • IIS -
+4

Source: https://habr.com/ru/post/1540842/


All Articles