Hi All,

I need to get the site information from an IP address. Does anyone
know if it is possible to run some kind of query against the Active
Directory to get the site name of a given IP address?

Cheers
Thomas

Re: Site from IP by Rafael

Rafael
Mon May 02 19:04:34 CDT 2005

Thomas,

You can try DNS lookup to get the domain name however it is not AD.

to do a lookup, open the command prompt and type:

nslookup ipaddress
It should return with the domain name if it is assigned.

*I don't think there is an AD way to do that from IP because of security
reasons, but if it is in your own internal network you can query your dns
server directly for a list of ips and names.
Rafael

"lupo" <nospam@wolf-da.de> wrote in message
news:964d6dcd.0505020852.1329299a@posting.google.com...
> Hi All,
>
> I need to get the site information from an IP address. Does anyone
> know if it is possible to run some kind of query against the Active
> Directory to get the site name of a given IP address?
>
> Cheers
> Thomas



Re: Site from IP by Torgeir

Torgeir
Tue May 03 12:12:37 CDT 2005

lupo wrote:

> Hi All,
>
> I need to get the site information from an IP address. Does anyone
> know if it is possible to run some kind of query against the Active
> Directory to get the site name of a given IP address?
Hi,

Robbie Allen has code for listing all defined subnets in his Active
Directory Cookbook.

Fortunately, the scripts that comes with this book is also available
on the Web for free:

Go to http://www.rallenhome.com/scripting.html and select "Browse
source code" for "Active Directory Cookbook"

See the following script there:

11.5. Listing the subnets


Change the line
Wscript.Echo " " & objSubnet.Get("cn")

to
Wscript.Echo objSubnet.Get("cn") & " " & objSubnet.Get("siteObject")



I would think you should be able to use an ADO search to search Active
Directory for a spesific subnet, using the configurationNamingContext
value as a base for the search, like this:

set objRootDSE = GetObject("LDAP://RootDSE")
strConfig = objRootDSE.Get("configurationNamingContext")
strBase = "<LDAP://" & strConfig & ">"

More about ADO search here:
http://www.rlmueller.net/ADOSearchTips.htm


--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx