Reputation: 18760
I have an ASP.NET application, which runs on machine 1.
When a user access that page from machine 2, I want to find out the user name, under which he or she is logged in on 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 it doesn't work.
Request.LogonUserIdentity.Name
returns NT AUTHORITY\IUSR
, Request.LogonUserIdentity.User
- S-1-5-17
, all others - empty strings. NT AUTHORITY\IUSR
is the user on the machine, on which the web application runs, not the user on the client machine.
In web.config
I disabled impersonation using
<authentication mode="Windows"/>
<identity impersonate="false"/>
What can I do in order to get the user name of the user, who accesses the web page?
Upvotes: 5
Views: 5048
Reputation: 157098
You have to set the authentication in IIS to Windows Authentication (and probably disable all others):
Go to:
Upvotes: 5