How to get current PC Username?



Feb 10 2017 12:42 AM
I want to implement single sign on.
I get the user name of local pc using many codes(Given below)
string hostName = System.Net.Dns.GetHostName();
string fff= System.Environment.GetEnvironmentVariable("UserName");
string ff=Request.LogonUserIdentity.Name.Substring(Request.LogonUserIdentity.Name.LastIndexOf(@"\") + 1);

string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
These codes are get the pc user name but i after host to server these codes are get only server pc name not get local pc name.

string fff= System.Environment.GetEnvironmentVariable("UserName");

the above code i used my local code these is get the local pc name after

i host my application this is get the user name of LOCAL PC Computer name not get user name of local PC

How to fix it.


Answers (6)