0

Could someone please provide some assistance with VBS scripting?

Here is what I have modified so far;

Const GROUP1 = "cn=GROUP1"
Const GROUP2 = "cn=GROUP2"
Const GROUP3 = "cn=GROUP3"

Set wshNetwork = CreateObject("WScript.Network")

Set ObjectUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ObjectUser.UserName)
strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, LCase("GROUP1")) Then   
  wshNetwork.MapNetworkDrive "L:", "\\servername\\volume1\"
End If

If InStr(strGroups, LCase("GROUP2")) Then
  wshNetwork.MapNetworkDrive "M:", "\\servername\volume2\"
End If

If InStr(strGroups, LCase("GROUP3")) Then
  wshNetwork.MapNetworkDrive "N:", "\\servername\volume3\"
End If

I am unsure of how best and easiest way to retreive LDAP string? I also keep getting an error on Set CurrentUser = GetObject("LDAP://" & ObjectUser.UserName).

Any help would be much appreciated.

2
  • 1
    We need a bit more detail. What LDAP string are you trying to retreive? What error are you receiving?
    – uSlackr
    Mar 13, 2012 at 13:00
  • Also note that this won't work right with nested group membership. You would need to traverse through the groups.
    – Nate
    Mar 13, 2012 at 13:31

2 Answers 2

6

It would be much easier if you used Group Policy Preferences to map the drives and did item-level targeting to filter drive maps by group. This is the preferred way.

1

I'm sure there have been a hundred & one solutions to mapping drives based on group membership. You can find mine here. It uses vbscript for some of this and cmd shell for others. Perhaps you don't need to reinvent the wheel.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .