Listing14_Transfer_PDC (VBScript)

This code can be found in Chapter 7 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

ON ERROR RESUME NEXT

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

' Update the becomePDC operational attribute
Dim ldapObj, rootDSE
Set ldapObj = GetObject("LDAP:")
' Requires a bind to the RootDSE
Set rootDSE = ldapObj.OpenDsObject("LDAP://" & server & "/RootDSE", _
                                   user, passwd, 1)
rootDSE.Put "becomePDC", 1
rootDSE.SetInfo

If Err.Number then
    Wscript.Echo "Could not transfer FSMO: " _
                 & Err.Description
Else
   Wscript.Echo  "Successfully initiated FSMO transfer to " & server
End If

This code has been viewed 737 times.

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