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
| Dim objRootLDAP, objGroup, objUser, objOU, objmemberOf
Dim strOU, strUser, strDNSDomain, strLDAP, List, objADSysInfo,arr,intlength,intNamelength,strGroupName
' Commands to bind to AD
Set objRootLDAP = GetObject("LDAP://RootDSE" )
Set objNetwork = CreateObject("Wscript.Network" )
'trouver le DN de l'utilisateur
Set objADSysInfo = CreateObject("ADSystemInfo" )
strUser = objADSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
' Extract a list of Groups from memberOf
objmemberOf = objUser.GetEx("memberOf" )
For Each objGroup in objmemberOf
List = List & objGroup & vbCr
arr=Split(List,"," )
intlength=Len(arr(0))
intNamelength=intlength - 3
Next
strGroupName= Right(arr(0), intNameLength)
'Connecter un lecteur en fonction du groupe
Select Case strGroupName
Case "GROUP1"
objNetwork.MapNetworkDrive "m:", "\\monserveur\GROUP1"
Case "GROUP2"
objNetwork.MapNetworkDrive "o:", "\\monserveur\GROUP2"
End Select
WScript.Quit |
Partager