Solved

NSLookup in ASP

Posted on 2012-04-05
7
638 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
key press alert 2 47
Asp in script 6 51
window close link 7 62
SQL help please 15 36
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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 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