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 59 60 61 62 63 64 65 66
| intRaw = 2
Do Until WsSource.Cells(intRaw, 15).Value = ""
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Assignation de chaque colonne Excel dans une variable
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
nom = WsSource.Cells(intRaw, 1).Value
prenom = WsSource.Cells(intRaw, 2).Value
ville = WsSource.Cells(intRaw, 3).Value
intMDP = WsSource.Cells(intRaw, 4).Value
objOU = WsSource.Cells(intRaw, 10).Value
loggin = WsSource.Cells(intRaw, 15).Value
messagerie = WsSource.Cells(intRaw, 16).Value
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Choix du domaine et du conteneur d'Active Directory
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set objDomain = GetObject("LDAP://OU=" & objOU & ",dc=monserveur,dc=com")
Set objCN = GetObject("LDAP://OU=" & objOU & ", dc=monserveur,dc=com")
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Création de l'utilisateur "# i" et assignation des valeurs: loggin, nom, prénom, bureau _
' messagerie, ville et password
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set WbSource = objCN.Create("user", "CN=" & nom & " " & prenom)
WbSource.Put "UserPrincipalName", loggin
WbSource.Put "sAMAccountName", loggin
WbSource.Put "sn", nom
WbSource.Put "givenName", prenom
WbSource.Put "Name", nom & " " & prenom
WbSource.Put "displayName", nom & " " & prenom
WbSource.Put "physicalDeliveryOfficeName", objOU
WbSource.Put "mail", messagerie
WbSource.Put "l", ville
WbSource.SetInfo
Set WbSource = GetObject("LDAP://cn=" & nom & " " & prenom & ",OU=" & objOU & ", dc=monserveur, dc=com")
WbSource.userAccountControl = 512
WbSource.SetPassword intMDP
WbSource.SetInfo
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Activation du compte
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'Set WbSource = GetObject("LDAP://cn=" & nom & " " & prenom & ", OU=" & NomCible & ", dc=monserveur, dc=com")
WbSource.AccountDisabled = False
WbSource.SetInfo
liste = liste + nom & ", "
intRaw = intRaw + 1
Loop |
Partager