Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

NSLookup in ASP

Posted on 2012-04-05
7
Medium Priority
?
710 Views
Last Modified: 2012-06-21
What is the easiest way to get a client host name in an ASP page?

comp_name=Request.ServerVariables("REMOTE_HOST")

Open in new window


This will give me my client IP address but I need to get the host computer name not address.
Is there and easy lookup tool or another syntax I can use?

Thanks
0
Comment
Question by:piemckay
  • 4
  • 3
7 Comments
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 37811851
<%
  Set PCName = Server.CreateObject("WScript.Network")
  Response.Write PCName.ComputerName
%>
0
 

Author Comment

by:piemckay
ID: 37811901
This returns the server name not the client name.

Thanks though! Any other ideas?
0
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 37811950
What do you mean by client name?

It returns the name of the computer you run it agains, server or no server.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:piemckay
ID: 37811982
The computer I am accessing the asp page through is the client. I want it to set comp_name to the name of my computer. For example my computer is called "API-GRP-WRK-445", the asp page is hosted on our IIS server "API-SVR-IIS-00".

When i use your code it will return the comp_name as "API-SVR-IIS-00" not "API-GRP-WRK-445".

Output
0
 
LVL 29

Expert Comment

by:sammySeltzer
ID: 37812135
You may have to ping the ip address yourself to get the computer name using the following command:

ping -a ipaddress
0
 

Accepted Solution

by:
piemckay earned 0 total points
ID: 37812253
Thanks for pointing me in the right direction. I used this

Dim comp_name
Dim oShell, oExec, sCommand, sOutput
comp_name= Request.ServerVariables("REMOTE_HOST")
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

comp_name = sOutput 

Open in new window


Works perfect! Pity there is no simplie way of doing it.
0
 

Author Closing Comment

by:piemckay
ID: 37826766
This worked perfectly, it essentially is the only way to resolve a client IP address to a host name by pinging it and getting the results of that ping which includes the host name.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question