Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
1  
We need a bit more detail. What LDAP string are you trying to retreive? What error are you receiving? –  uSlackr Mar 13 '12 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 '12 at 13:31

2 Answers 2

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.