Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client Machine Name and User Name

Status
Not open for further replies.

DilipKS

Programmer
Mar 8, 2004
30
CH
hi
am trying to get client machine name and the user name on that machine. Any idea ?
I am trying to use -
System.Net.Dns.GetHostName() or System.Environment.MachineName
but i guess they both gives server name ...not client name

For User I am using - System.Environment.UserName
but it gives ASPNET user , I want to know the user name who is running that ASP page at client side .
 
Check out the Request.ServerVariables collection. Amongst many other useful variables you can get username using...

Request.ServerVariables["LOGON_USER"]

This is also available from the .NET Framework

HttpContext.Current.User.Identity.Name

You cannot get machinename as easily. The server variables collection does include IP though

Request.ServerVariables["REMOTE_ADDR"]

Thias can be resolved to a machine name using the Dns class in the System.Net namespace. I havent done this but you should be able to do a reverse lookup from IP using

System.Net.Dns.GetHostByAddress(IPAddress);

HTH

Rob


Go placidly amidst the noise and haste, and remember what peace there may be in silence - Erhmann 1927
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top