Ao executar o script abaixo, recebo o erro: Object NULL - Não há tal objeto no servidor.
O que pode ser??
----------------------------------------
Dim oFSO, sFile, oFile, sText, strUsername, strDomain, objUser, info, objOU
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFile = "c:\usuarios.txt"
If oFSO.FileExists(sFile) Then
Set oFile = oFSO.OpenTextFile(sFile, 1)
Do While Not oFile.AtEndOfStream
sText = oFile.ReadLine
If Trim(sText) <> "" Then
strUsername= sText
UserDN = buscaDN(strUsername)
If UserDN <> "" Then
' Set objUser = GetObject("LDAP://" & UserDN)
' intUAC = UserObj.Get("userAccountControl")
Set objOU = GetObject("LDAP://" & UserDN)
objOU.Delete "user", UserDN
End If
End If
Loop
oFile.Close
End If
Function buscaDN(ByVal nomeUsuario)
Dim oRootDSE, oConnection, oCommand, oRecordSet
' Set oRootDSE = GetObject("LDAP://rootDSE")
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Open "Provider=ADsDSOObject;"
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnection
oCommand.CommandText = "LDAP://rootdse;(&(objectCategory=User)(samAccountName=" & nomeusuario & "));distinguishedName;subtree"
Set oRecordSet = oCommand.Execute
On Error Resume Next
buscaDN = oRecordSet.Fields("DistinguishedName")
On Error GoTo 0
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
Set oRootDSE = Nothing
End Function
--------------------------------------------------