1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
On Error Resume Next
dim objfichier, myfile, Ouchoisi
const forReading = 1, ForWritting = 2, ForAppending = 8
Const ADS_SCOPE_SUBTREE = 2
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") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
OuChoisi=inputbox ("veuillez Choisir l'Unité d'organisation que vous voulez inspecter","Choix de l'OU")
objCommand.CommandText = _
"SELECT AdsPath FROM 'LDAP://OU="& OuChoisi &", dc=mjs, dc=local' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
set objfichier = createobject("scripting.filesystemobject")
NomFichier=inputbox ("Veuillez entrez le nom de fichier","Nom du Fichier")
set myfile = objfichier.opentextfile(NomFichier, forwritting, true)
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Set objUser = GetObject(objRecordSet.Fields("AdsPath").Value)
If objUser.AccountExpirationDate > date Then
Myfile.writeline objUser.SamAccountName
End If
objRecordSet.MoveNext
Loop |
Partager