I map users drives based on Active Directory group membership (use same group name to publish application to that user).
It deletes all mapped drives, then readds after checking active directory for group membership (based on username).
You can use this by saving the following script to c:\windows\system32\map_drives.vbs adding the following line to your c:\system32\usrlogon.bat
wscript map_drives.vbs
=================================================
Set objNetwork = CreateObject("WScript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
UserName = CreateObject("WScript.Shell").ExpandEnvironmentStrings("%username%")
On Error Resume Next
For i = 0 to colDrives.Count-1 Step 2
objNetwork.RemoveNetworkDrive colDrives.Item(i)
Next
If IsMember("ActiveDirectoryGroupName1") = "True" Then
objNetwork.MapNetworkDrive "P:", "\\share\subfolder"
End If
If IsMember("ActiveDirectoryGroupName2") = "True" Then
objNetwork.MapNetworkDrive "L:", "\\share\subfolder"
End If
If IsMember("ActiveDirectoryGroupName3") = "True" Then
objNetwork.MapNetworkDrive "N:", "\\share\subfolder"
End If
If IsMember("ActiveDirectoryGroupName4") = "True" Then
objNetwork.MapNetworkDrive "M:", "\\share\subfolder"
End If
' This function checks to see if the passed group name contains the current computer as a member. Returns True or False
Function IsMember(groupName)
If IsEmpty(groupList) then
Set groupList = CreateObject("Scripting.Dictionary")
groupList.CompareMode = TextCompare
ADSPath = "cmcinet.org" & "/" & UserName
Set userPath = GetObject("WinNT://" & ADSPath & ",user")
For Each listGroup in userPath.Groups
groupList.Add listGroup.Name, "-"
Next
End if
IsMember = CBool(groupList.Exists(groupName))
End Function