Solved

NSLookup in ASP

Posted on 2012-04-05
7
626 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 28

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 28

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 28

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

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!

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

713 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