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 67
| dim oConnection,oRecordset
' Connexion de type base de donnée à Active Directory
Set oConnection = CreateObject("ADODB.Connection")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
' Définition de la recherche principale
Set oRecordset = oConnection.Execute("<LDAP://OU=agence,DC=Local,DC=com>;(&(objectCategory=user));sAMAccountName,mail,distinguishedName,msRTCSIP-UserEnabled,msRTCSIP-PrimaryHomeServer;subtree")
' Boucle sur les enregistrements
If Not oRecordset.EOF Then
While Not oRecordset.EOF
currentuser=oRecordset.Fields("sAMAccountName")
If (isnull(oRecordset.Fields("mail"))) then
'u=u+1
Dim oUser
set oUser= GetObject("LDAP://"+oRecordset.Fields ("distinguishedName"))
'Distinctin bureaux - agences
if mid(currentuser,1,2) = "b-" then
mail = mid(currentuser,3,len(currentuser)-2) & "@local.com"
else
mail = currentuser & "@local.com"
end if
If (isnull(oRecordset.Fields("msRTCSIP-UserEnabled"))) then 'permet de d'activer la case à cocher dans les propriétés lcs d'un user.
'UserEnabled = TRUE
End if
PrimaryHomeServer = "LCS2005.local.com" 'renseigne juste apres la case à cocher le nom du serveur LCS actuel.
Wscript.echo("msRTCSIP-PrimaryHomeServer")
'Mise à jour du champ Mail et LCS
oUser.put "Mail", Mail
oUser.put "msRTCSIP-UserEnabled", msRTCSIP-UserEnabled
oUser.put "PrimaryHomeServer",PrimaryHomeServer
oUser.SetInfo
End if
oRecordset.movenext
wend
End If
wscript.echo "Enregistrement terminé !"
wscript.quit |
Partager