Atena
Atena

Reputation: 1

How can I get current user in windows?

I have a web program In asp.net and c#. In my application I want get the current windows username and save it on a variable.If I run my app in local I can do it easily but when I run my app from server How can I do it? It means How can I get current user from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows \CurrentVersion\ Authentication /LogonUI and save it on a variable?

Upvotes: 0

Views: 148

Answers (2)

freshrebel
freshrebel

Reputation: 1

in c# you can get the windows identity by string variable = System.Environment.UserName

i hope this helped.

Upvotes: 0

nvoigt
nvoigt

Reputation: 77364

You cannot do this. You cannot get the logon username of the computer that the web browser is running on. And for good reasons, you would read data that you have no business reading. If you need that username, have the user enter it.

Upvotes: 1

Related Questions