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 52 53 54 55 56 57 58
| '## debut script###
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set oContainer = GetObject("LDAP://dc=integration,dc=local")
ConvertUsers (oContainer)
Set oContainer = Nothing ' Nettoyage de mémoire
WScript.Quit
Sub ConvertUsers(oTopLevelContainer)
Dim oObj
For Each objUser In oTopLevelContainer
Select Case objUser.Class
Case "organizationalUnit", "container"
ConvertUsers (objUser)
Case "user"
Dim fso, df1
CSVFile = "c:\temp\adusers.csv"
Set fso = CreateObject("Scripting.FileSystemObject")
Set df1 = fso.OpenTextFile(CSVFile, ForReading, True)
Do While Not df1.AtEndOfStream
varLigne = df1.readline()
If UBound(Split(varLigne, ",")) < 2 Then '*** debut partie modifiée ***
MsgBox "contenu de varLigne: " & vbNewLine & varLigne '*** partie modifiée *********
Else '*** partie modifiée *********
Noms = Split(varLigne, ",")(0) '*-- reprise de ton code *****
samaccountname = Split(varLigne, ",")(1) '*---- mais inclut dans -----*
userprincipalname = Split(varLigne, ",")(2) '*---- la condition If ------*
'msgbox ""& session
'msgbox ""& CNUser
If CNUser = objUser.cn Then
MsgBox "ok pour" & Noms
'Set oobj = GetObject ("LDAP://cn=" & Noms & ",dc=integration,dc=local")
objUser.Put "userprincipalname", "" & userprincipalname
objUser.Put "samaccountname", "" & samaccountname
objUser.setinfo
End If
End If '*** Fin partie modifiée *****
Loop
df1.Close
End Select
' Va à la prochaine OU enfant
Next
End Sub
'## fin script### |
Partager