Link to home
Start Free TrialLog in
Avatar of ieckhaa
ieckhaa

asked on

Get client computer name or client user name

I had a web site running with ASP.
I want to know who visit my site. Instead of knowing their IP address, how can i get the client Computer name or User Name..

Eg. Tom surf my site through IE browser, and i would like to log down Tom' PC info like Computer name and User Name...
so what i expect to have once he click on my Page is: (for example)
Computer Name: Tom_PC
User Name: TOM

Many Thanks
Avatar of Sashi Rachabattula
Sashi Rachabattula
Flag of India image

Try this to get the computer name. However it gives a very ugly dialog box saying ActiveX control is used!
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
       var wshNetwork = new ActiveXObject("WScript.Network");
    alert(wshNetwork.ComputerName);
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>

Avatar of ieckhaa
ieckhaa

ASKER

it seems not work as Error message pop up said "Automation Server Can't create object"
I don't think there is a way to get the username and computername without creating an ActiveX object (the ugly dialog box). Allowing the dialog box, you can retrieve the information this way:

Dim objNet
On Error Resume Next 'In case we fail to create object then display our custom error
Set objNet = CreateObject("WScript.NetWork")
If  Err.Number <> 0 Then                'If error occured then display notice
     MsgBox "Don't be Shy." & vbCRLF &_               "Do not press ""No"" If your browser warns you."
     Document.Location = "UserInfo.html"                                               'Place the Name of the document.
                                     'It will display again
End if
     
Dim strInfo
strInfo = "User Name is     " & objNet.UserName & vbCRLF & _
          "Computer Name is " & objNet.ComputerName & vbCRLF & _
          "Domain Name is   " & objNet.UserDomain
MsgBox strInfo
     
Set objNet = Nothing                    'Destroy the Object to free the Memory
Avatar of ieckhaa

ASKER

thanks to Marno, but the result is not expected. Since i want to get client PC's Computer name and USER ID, the result is the server name and IIS anonymous USER ID.. would it be the only to get using Javascript???

Please help
You can get the NT-username logged on to the computer by using request.servervariables("LOGON_USER") if that is what you want.
Avatar of ieckhaa

ASKER

thanks Marno, i've try this before but it returns nothing ...
It depends on wether the user has logged on to the computer or not. If the user for example is on a win2k computer and has logged on it will show up. If the user has a win98 computer that automatically starts up without having to log on, the result will be empty.

What I know, for security reasons, there is no other way to get the user's computer name.
Avatar of sybe
For obvious reasons some information is not send to the server. That includes:

the PC-name
the user's name
the user's email address
the user's home address
the user's telephone number
the user's age
the legal software installed on the machine
the ilegal software installed on the machine
etc.

If you want those, you'l have to ask the user. But remember: the user is allowed to lie.
You can request the Windows NT Login user with this code:

<% User = mid(LCase(Request.ServerVariables("LOGON_USER")),InstrRev(LCase(Request.ServerVariables("LOGON_USER")),"\")+1) %>

But you've tho disable the anonymos login in your IIS Filedirectory, and it work only on IExplorer as far as i know.

How to request the computer name ? i've no idea - sorry.

I hope i could help.
The LOGON_USER is only available when the anonymous access is disabled.

IE can be used with "integrated security" (or whatever it is called), which means that within a domain (intranet) no username/password is asked, but that IE uses the username/password which was used to login to the computer.

Avatar of ieckhaa

ASKER

If so, can i write the client program like Javascript to get the local client's USER NAME and COMPUTER NAME?? and then pass back to the server...

Many thanks
ASKER CERTIFIED SOLUTION
Avatar of sybe
sybe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial