| Map Network Drive based on Group Membership |
|
|
| Written by Oscar Sodani | |
| Thursday, 19 June 2008 | |
|
One caveat, however: the user must belong to at least 2 groups for this to work. What I did was to make sure that all my users were in a generic Domain Users group first, or create your own generic group for everyone. The reason for this is that the script expects the number of group memberships to be greater than 1. Here is the relevant part of the script I am now using (simply replace the group names, share names, and server name with your own):
On Error Resume Next Set objSysInfo = CreateObject("ADSystemInfo") Set objNetwork = CreateObject("Wscript.Network") strUserPath = "LDAP://" & objSysInfo.UserName Set objUser = GetObject(strUserPath) For Each strGroup in objUser.MemberOf strGroupPath = "LDAP://" & strGroup Set objGroup = GetObject(strGroupPath) strGroupName = objGroup.CN Select Case strGroupName Case "JuniorHigh" objNetwork.MapNetworkDrive "J:", "\\SERVERNAME\JuniorHighShare" Case "HighSchool" objNetwork.MapNetworkDrive "K:", "\\SERVERNAME\HighSchoolShare" Case "LowerSchool" objNetwork.MapNetworkDrive "L:", "\\SERVERNAME\LowerSchoolShare" End Select Next
|
| Next > |
|---|






