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 43 44 45 46 47 48 49 50 51
| Dim oContainer
Dim OutPutFile
Dim OutPutFileLog
Dim FileSystem
Dim PropArray
Dim entete,ouser
'On ERROR RESUME NEXT
Server = "localhost"
Port = "389"
Instance = "Annuaire"
OU = "OU=Ut,OU=personnes"
OU2 = "OU=bureau"
'Initilisation des variables globales
Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
Set OutPutFile = FileSystem.CreateTextFile("C:\Perso\Utilisateurs.csv", True)
set oContainer=GetObject("LDAP://" & Server & ":" & Port & "/" & OU & ",CN=" & Instance & ",dc=workgroup")
set oConAgence=GetObject("LDAP://" & Server & ":" & Port & "/" & OU2 & ",CN=" & Instance & ",dc=workgroup")
exportUsers oContainer,oConAgence
OutPutFile.Close
'OutPutFileLog.Close
Set FileSystem = Nothing
Set oContainer = Nothing
WScript.Echo "Finished"
WScript.Quit(0)
function exportUsers (oContainer,oConAgence)
'Dim tabStr
'tabstr=Split(entete, ";")
On Error resume next
'Wscript.Echo oCont.Class
'oCont.filter = Array("user")
For Each ouser In oContainer
wscript.echo ouser.name
OutPutFile.Write ouser.cn & ";"
OutPutFile.Write ouser.sn & ";"
OutPutFile.Write ouser.givenName & ";"
OutPutFile.writeLine oUser.title
Next
OutPutFile.WriteLine
End function |
Partager