Solved

NSLookup in ASP

Posted on 2012-04-05
7
562 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
Comment Utility
<%
  Set PCName = Server.CreateObject("WScript.Network")
  Response.Write PCName.ComputerName
%>
0
 

Author Comment

by:piemckay
Comment Utility
This returns the server name not the client name.

Thanks though! Any other ideas?
0
 
LVL 28

Expert Comment

by:sammySeltzer
Comment Utility
What do you mean by client name?

It returns the name of the computer you run it agains, server or no server.
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:piemckay
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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/…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now