Glory to Russia
Glory to Russia

Reputation: 18760

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

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

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

Answers (1)

Patrick Hofman
Patrick Hofman

Reputation: 157098

You have to set the authentication in IIS to Windows Authentication (and probably disable all others):

enter image description here

Go to:

  • Website
  • IIS - Authentication
  • Edit according your wishes

Upvotes: 5

Related Questions