ComputerName of Remote User

D

dthmtlgod

I am attempting to retrieve the computer name of a remote user accessing our
websever. I have tried the following and both don't work. Any ideas?


Returns the webserver computer name

Set WshNetwork = CreateObject("WScript.Network")
response.write (wshNetwork.ComputerName)

Also tried this and I get a permissions error.

Set Sys = CreateObject("ADSystemInfo")
response.write (sys.ComputerName)
 
R

Ray Costanzo [MVP]

The Web server will have the IP address of the remote computer, assuming
there is no proxy server, firewall, etc. between the remote computer and
your server. So, if you have the IP address, you can attempt to do a
reverse DNS lookup to convert the IP to the hostname. The quick and dirty
way to do it would be to "ping -a" the IP. Ping with the -a switch will
attempt to resolve the IP to a hostname.

Example:

<%
Dim sIP
Dim oShell, oExec, sCommand, sOutput
sIP = Request.ServerVariables("REMOTE_ADDR")
sCommand = "%comspec% /c @echo off & for /f ""tokens=2"" %q in ('ping -n
1 -a " & sIP & "^|find /i ""pinging""') do echo %q"
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec(sCommand)
sOutput = oExec.StdOut.ReadAll
Set oExec = Nothing
Set oShell = NOthing
Response.WRite sOutput
%>

Ray at work
 
D

dthmtlgod

Thanks a lot Ray, firewall is preventing me from obtaining the computer
name. Token 2 is the IP address.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top