0

I need to get my logged in Windows user name, from the PC I am using to the server hosting my site.

In my code I have the following line:

  var user = WindowsIdentity.GetCurrent().Name;

When I run my project locally it returns what I expect: myComputer\UserAccountName

However, when I deploy my site to my server, it is picking up my servers username: myServer\ServerAccountName

What is the call that I need to make in order to correctly pass down UserAccountName and not have the ServerAccountName used instead?

Sean
  • 897
  • 4
  • 20
  • 42
  • Are you talking about an ASP.Net application? If so the only way for that to happen automatically is to configure [Windows Authentication](https://learn.microsoft.com/en-us/iis/configuration/system.webserver/security/authentication/windowsauthentication/) which is probably not what your looking for. – Alex K. Apr 04 '19 at 15:21

1 Answers1

0

can you not use the following?

User.Identity.Name;
dtroy
  • 36
  • 6