Const ADS_SECURE_AUTHENTICATION = &H1
Const ADS_USE_ENCRYPTION = &H2
Const ADS_SERVER_BIND = &H200
strNewOUPath = "LDAP://dcserver.domain.com/OU=Computers,OU=MainSite,OU=Sites,dc=domain,dc=com"
strComputerPath = "LDAP://CN=ComputerNameToMove,ou=IT Computers,OU=MainSite,OU=Sites,dc=domain,dc=com"
strUser = "domain\administrator"
strPassword = InputBox("Enter password:")
Set objDSO = GetObject("LDAP:")
Set objNewOU = objDSO.OpenDSObject(strNewOUPath, strUser, strPassword, ADS_SECURE_AUTHENTICATION + ADS_SERVER_BIND)
On Error Resume Next
objNewOU.MoveHere strComputerPath, vbNullString
If Err.Number = 0 Then
MsgBox "Computer moved successfully."
Else
MsgBox "Error " & Err.Number & ": " & Err.Description
End If
|