'# From the book "Managing Enterprise Active Directory Services"
'# ISBN: 0-672-32125-4
Dim user, passwd, server, subnets_dn, ldapObj, subnetsObj, subnetObj
Dim count, site_dn, regexObj, site
server = "dc1.xyz.com"
user = "administrator@xyz.com"
passwd = "password"
subnets_dn = "cn=subnets,cn=sites,cn=configuration,dc=xyz,dc=com"
Set ldapObj = GetObject("LDAP:")
Set subnetsObj = ldapObj.OpenDsObject("LDAP://" & server & "/" & subnets_dn, _
user, passwd, 1)
subnetsObj.Filter = Array("subnet")
count = 0
On Error Resume Next
For Each subnetObj in subnetsObj
count = count + 1
site_dn = subnetObj.Get("siteObject")
' strip off everything but the name from the site DN
Set regexObj = New RegExp
regexObj.Pattern = "^cn=(.+),cn=sites,cn=configuration,.+$"
regexObj.IgnoreCase = True
site = regexObj.Replace(site_dn,"$1")
Wscript.Echo count & ". " & subnetObj.cn & " (" & site & ")"
Next
|