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
| Dim oexapp, oexwk, oexws, owshshell, ocellule, i
dim nom, prenom, loggin, mdp, liste
'liste = ""
set oexapp = wscript.createobject("Excel.Application")
set owshshell = wscript.createobject("wscript.shell")
oexapp.visible = false
set oexwk = oexapp.workbooks.open(owshshell.currentdirectory & "\utilisateurs.xls")
set oexws = oexwk.activesheet
'oexapp.visible=true
Dim MonDomaine
MonDomaine="dc=MyServer, dc=local"
Set objCN = GetObject("LDAP://OU=MesUsers,OU=Utilisateurs," & MonDomaine)
Set objGroup = GetObject("LDAP://CN=Utilisa. du domaine, CN=Users," & MonDomaine)
Set objGroup = GetObject("LDAP://CN=Utilisa. du domaine, CN=Users," & MonDomaine)
i = 2
Do until oexapp.cells(i,2).value = ""
nom = oexapp.cells(i,1).value
prenom = oexapp.cells(i,2).value
loggin = oexapp.cells(i,3).value
mdp = oexapp.cells(i,4).value
wscript.echo "création compte " & nom
'Set objDomain = GetObject("LDAP://dc=MyServer, dc=local")
Set objUser = objCN.Create("User", "cn= " & nom & "")
objUser.Put "sAMAccountName", loggin
objUser.Put "sn", nom
objUser.Put "givenName", prenom
objUser.SetInfo
Set objUser = GetObject("LDAP://cn=" & nom & ",OU=MesUsers,OU=Utilisateurs," & MonDomaine)
objUser.SetPassword mdp
objGroup.Put "sAMAccountName", "Utilisa. du domaine"
Set objUser = GetObject("LDAP://cn=" & nom & ", OU=MesUsers,OU=Utilisateurs," & MonDomaine)
objUser.AccountDisabled = FALSE
objUser.SetInfo
'liste = liste + nom & ", "
i = i+1
Loop
'MsgBox "Les utilisateurs " & liste & " ont été créés et activés."
oexapp.quit |
Partager