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