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 68 69 70 71 72 73 74 75 76
|
on error resume next
Dim objRootLDAP, objGroup, objUser, objOU, objmemberOf
Dim strOU, strUser, strDNSDomain, strLDAP, List, objADSysInfo,arr,intlength,intNamelength,strGroupName,groupe2
Set WSHNetwork = WScript.CreateObject("WScript.Network")
Set UserName = GetObject("WinNT://" & WSHNetwork.UserDomain & "/" & WshNetwork.username)
Set objRootLDAP = GetObject("LDAP://RootDSE" )
Set objNetwork = CreateObject("Wscript.Network" )
Set objADSysInfo = CreateObject("ADSystemInfo" )
strUser = objADSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
'=============================================================================================================
'Suppression de toutes les imprimantes à l'exeption de celle par defaut
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstalledPrinters = objWMIService.ExecQuery _
("Select * from Win32_Printer Where Default = FALSE AND Network = TRUE")
For Each objPrinter in colInstalledPrinters
objPrinter.Delete_
Next
'=============================================================================================================
'Récupération de la liste des groupes Active Directory
'EN TEST#######################################################################################################
objmemberOf = objUser.GetEx("memberOf" )
For Each objGroup in objmemberOf
List = List & objGroup & vbCr
arr=Split(List,"," )
intlength=Len(arr(0))
intNamelength=intlength - 3
groupes2 = Split(objGroup,",",2)
groupeHp = Groupe2
groupeDiv = Groupe2
groupeRicoh = Groupe2
'#######################################################################################################
'groupe = groupe2_sans_les_3_premier caractéres
'groupes2 affiche CN=GROUPE --> A modifier afin de n'avoir que GROUPE
'groupe
'#######################################################################################################
'=============================================================================================================
'Liste des groupes de l'OU IMPR64-HP
Set objOUHp = GetObject("LDAP://OU=IMPR64-HP,OU=DOMAINE,DC=DOM,DC=LOCAL")
objOUHp.Filter = Array("Group")
For Each objGroupHp in objOUHp
If objGroupHp.Name = groupeHp(0) Then
wscript.echo "OK HP"
WshNetwork.AddWindowsPrinterConnection "\\IMPR64-HP\MATT_IMP_16" 'Forcé en dur le temps que la variable groupe soir OK
'WshNetwork.AddWindowsPrinterConnection "\\IMPR64-HP\" & groupe ' Sera utilisé quand la varible groupe sera OK
End If
Next
'=============================================================================================================
'Liste des groupes de l'OU IMPR64-DIV
Set objOUDiv = GetObject("LDAP://OU=IMPR64-DIV,OU=DOMAINE,DC=DOM,DC=LOCAL")
objOUDiv.Filter = Array("Group")
For Each objGroupDiv in objOUDiv
If objGroupDiv.Name = groupeDiv(0) Then
wscript.echo "OK DIV"
WshNetwork.AddWindowsPrinterConnection "\\IMPR64-HP\MATT_IMP_23" 'Forcé en dur le temps que la variable groupe soir OK
'WshNetwork.AddWindowsPrinterConnection "\\IMPR64-DIV\" & groupe ' Sera utilisé quand la varible groupe sera OK
End If
Next
'=============================================================================================================
'Liste des groupes de l'OU IMPR64-RICOH
Set objOURicoh = GetObject("LDAP://OU=IMPR64-RICOH,OU=DOMAINE,DC=DOM,DC=LOCAL")
objOURicoh.Filter = Array("Group")
For Each objGroupRicoh in objOURicoh
If objGroupRicoh.Name = groupeRicoh(0) Then
wscript.echo "OK RICOH"
WshNetwork.AddWindowsPrinterConnection "\\IMPR64-HP\MATT_IMP_30" 'Forcé en dur le temps que la variable groupe soir OK
'WshNetwork.AddWindowsPrinterConnection "\\IMPR64-RICOH\" & groupe ' Sera utilisé quand la varible groupe sera OK
End If
Next
'=============================================================================================================
Next |
Partager