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
| Dim oexapp, oexwk, oexws, owshshell, ocellule, i
dim nom, prenom, loggin, mdp, liste, nomaff
'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"
'ex: MonDomaine="dc=Fondation-Auteuil, dc=com"
Set objCN = GetObject("LDAP://OU=Utilisateurs,OU=Client,OU=MesUsers," & MonDomaine)
'A modifier pour le site selon l'OU
'Exemple: Set objCN = GetObject("LDAP://OU=Utilisateurs,OU=Blanquefort St Joseph (BLA),OU=Fondation," & 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
nomaff = oexapp.cells(i,5).value
wscript.echo "création compte " & nom
'Set objDomain = GetObject("LDAP://dc=MyServer, dc=local")
Set objUser = objCN.Create("User", "cn= " & nomaff & "")
objUser.Put "sAMAccountName", loggin
objUser.Put "sn", nom
objUser.Put "givenName", prenom
objUser.SetInfo
Set objUser = GetObject("LDAP://cn=" & nomaff & ",OU=Utilisateurs,OU=Client,OU=MesUsers," & MonDomaine)
objUser.SetPassword mdp
objGroup.Put "sAMAccountName", "Utilisa. du domaine"
Set objUser = GetObject("LDAP://cn=" & nomaff & ",OU=Utilisateurs,OU=Client,OU=MesUsers," & 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