Listing16_Moving_Server (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 user, passwd, server, ldapObj, serverObj, dc, new_site, old_site
Dim sites_dn, new_serversCont_dn, old_servers_dn

' Move information
dc       = "dc2"
new_site = "RTP"
old_site = "Default-First-Site-Name"
sites_dn = "cn=sites,cn=configuration,dc=xyz,dc=com"

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

Set ldapObj = GetObject("LDAP:")
new_serversCont_dn = "cn=Servers,cn=" & new_site & "," & sites_dn
Set serverObj = ldapObj.OpenDsObject("LDAP://" & server & "/" & _
                                     new_serversCont_dn, user, passwd, 1)
old_servers_dn = "LDAP://" & server & "/cn=" & dc & ",cn=Servers,cn=" & _
                  old_site & "," & sites_dn

Wscript.Echo "Moving server " & dc
serverObj.MoveHere old_servers_dn, "cn=" & dc
Wscript.Echo "Server move complete"

This code has been viewed 749 times.

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