Question

Locked

VBS for Logon, increment drive letters

By BroadwayTech ·
I have the script below which functions fine for mapping drives according to group membership. Only issue is I have users that overlap so I need to change the drive letters if they have membership to more than one group. How can I achieve this? would you suggest a global variable that holds the drive letter and increments after each mapping? I appreciate any help.

Option Explicit
'Declare variables
Dim objNetwork, objUser, CurrentUser
Dim strGroup

' Initialize Groups with Const
Const Accounting_Group = "cn=Accounting"
Const Private_Group = "cn=SM_Private"
Const Public_Group = "cn=SM_Public"
Const Technology_Group = "cn=SM_Technology"
Const Corporate_Group = "cn=SM_Corporate"

' Create objects and extract strGroup values
Set objNetwork = CreateObject("WScript.Network")
Set objUser = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & objUser.UserName)

objNetwork.MapNetworkDrive "Q:", "\\server\Data"
objNetwork.MapNetworkDrive "I:", "\\server\Common"

strGroup = LCase(Join(CurrentUser.MemberOf))
' If logic testing strGroup for the values in Const groups
If InStr(strGroup, lcase(Corporate_Group)) Then
objNetwork.MapNetworkDrive "J:", "\\server\Corporate"
objNetwork.AddWindowsPrinterConnection "\\server\Executive-Suite"
objNetwork.SetDefaultPrinter "\\server\Executive-Suite"

ElseIf InStr(strGroup, lcase(Accounting_Group)) Then
objNetwork.MapNetworkDrive "K:", "\\server\Accounting"
objNetwork.AddWindowsPrinterConnection "\\server\Dell1815dn02"
objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC7345"
objNetwork.SetDefaultPrinter "\\server\Dell1815dn02"

ElseIf InStr(strGroup, lcase(Public_Group)) Then
objNetwork.MapNetworkDrive "M:", "\\server\Public_Equity_Market"
objNetwork.AddWindowsPrinterConnection "\\server\1815dn"
objNetwork.AddWindowsPrinterConnection "\\server\XeroxWC4150"
objNetwork.SetDefaultPrinter "\\server\1815dn(trade)"

ElseIf InStr(strGroup, lcase(Private_Group)) Then
objNetwork.MapNetworkDrive "N:", "\\server\Private_Company_Market"
objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)"
objNetwork.AddWindowsPrinterConnection "\\server\1815dn(trade)"
objNetwork.SetDefaultPrinter "\\server\1815dn(trade)"

ElseIf InStr(strGroup, lcase(Technology_Group)) Then
objNetwork.MapNetworkDrive "T:", "\\server\Tech"
objNetwork.AddWindowsPrinterConnection "\\server\Technology"
objNetwork.AddWindowsPrinterConnection "\\server\Dell3110"
objNetwork.SetDefaultPrinter "\\server\Technology"


End If

WScript.Quit

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Just create more groups.

by 1bn0 In reply to VBS for Logon, increment ...

Second group has same access as first but maps to a different drive letter.

Move users from the first group to the second group.

PITA but its a simple solution.


Other wise :

If user is a member of group1 and group2 map x

If user is a member of group1 map y
If user is a member of group2 map z

Back to Hardware Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums