Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- On Error Resume Next
- Const ADS_SCOPE_SUBTREE = 4
- Const ForReading = 1
- 'fichier generer avec AD-INFO SAMAccountName uniquement pour traité la job
- strCSV = "c:\2weekpast.csv"
- strDomain = "dc=chrg,dc=reg03,dc=rtss,dc=qc,dc=ca"
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objFile = objFSO.OpenTextFile(strCSV, ForReading)
- Do Until objFile.AtEndOfStream
- strLine = objFile.ReadLine
- arrLine = Split(strLine, ",")
- strAccount = arrLine(0)
- If LCase(strAccount) <> "samaccountname" Then
- Set objConnection = CreateObject("ADODB.Connection")
- Set objCommand = CreateObject("ADODB.Command")
- objConnection.Provider = "ADsDSOObject"
- objConnection.Open "Active Directory Provider"
- Set objCommand.ActiveConnection = objConnection
- 'protection anti buffer overflow, ne traiteras pas plus que 500 enregistrement
- objCommand.Properties("Page Size") = 500
- objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
- objCommand.CommandText = "SELECT AdsPath FROM 'LDAP://" & strDomain & _
- "' WHERE objectCategory='user' AND samaccountname='" & strAccount & "'"
- Set objRecordSet = objCommand.Execute
- objRecordSet.MoveFirst
- Do Until objRecordSet.EOF
- strUserPath = objRecordSet.Fields("AdsPath").Value
- Set objUser = GetObject(strUserPath)
- objUser.AccountDisabled = True
- objUser.SetInfo
- objRecordSet.MoveNext
- Loop
- End If
- Loop
- objFile.Close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement