miércoles, 23 de mayo de 2012

Script para desbloqueo de cuentas de Active Directory

Desbloquea los usuarios de AD de todo el directorio

'nivel de subárbol
Const ADS_SCOPE_SUBTREE = 5
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 10000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT distinguishedName,AdsPath FROM 'LDAP://dc=depo,dc=es' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set Flog = oFSO.CreateTextFile("cuentas.log")
'CANTIDAD = objRecordSet.RecordCount
if not objRecordset.eof then
    objRecordset.Movefirst
    while not objRecordset.eof
        Set objuser = GetObject(objRecordSet.Fields("AdsPath").Value)
              if objUser.IsAccountLocked = TRUE Then               
                Flog.Writeline("desbloqueando " & objRecordSet.Fields("distinguishedName").Value)
                objuser.put "lockoutTime", 0
                objUser.SetInfo
            end if             
              objRecordSet.MoveNext
    wend
end if
Flog.close

No hay comentarios:

Publicar un comentario

L2TP Ipsec Windows to Mikrotik eror 789

 Add this to registry REG ADD HKLM\SYSTEM\CurrentControlSet\Services\PolicyAgent /v AssumeUDPEncapsulationContextOnSendRule /t REG_DWORD /d...