5

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?

4
  • 4
    Is IIS set up to use Authentication? Sounds like Anonymous access is still enabled. Commented May 16, 2014 at 13:16
  • How can I find it out? Is it specified in the web.config? Commented May 16, 2014 at 13:17
  • 1
    No, it's a server-side setting. You can read more here Commented May 16, 2014 at 13:21
  • 1
    Actually , I would just like to thank you for asking that question cause i would need it's answer in few days Commented May 16, 2014 at 13:45

1 Answer 1

5

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
Sign up to request clarification or add additional context in comments.

2 Comments

I have the same problem, but wen I Enable windows Authentiation and disable all other, get 401 (Challenge) response.
Maybe your browser doesn't send the authentication well, or you are not part of the domain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.