Listing06_Delete_Site (VBScript)

This code can be found in Chapter 9 of Managing Enterprise Active Directory Services

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

'# From the book "Managing Enterprise Active Directory Services"
'# ISBN: 0-672-32125-4

Dim old_site, old_site_dn, user, passwd, server, siteObj, ldapObj

old_site = "RTP"

server = "dc1.xyz.com"
user   = "administrator@xyz.com"
passwd = "password"

' This could be dynamically computed using RootDSE
old_site_dn = "cn=" & old_site & ",cn=sites,cn=configuration,dc=xyz,dc=com"

Set ldapObj  = GetObject("LDAP:")
Set siteObj = ldapObj.OpenDsObject("LDAP://" & server & "/" & old_site_dn, _
                                    user, passwd, 1)
Wscript.Echo "Deleting site container for " & old_site
siteObj.DeleteObject(0)
Wscript.Echo "Site deletion complete"

This code has been viewed 645 times.

New from the creators of TechTasks.com: StatSheet.com