VB Login Script Help needed - TechRepublic
General discussion
October 18, 2006 at 08:09 AM
rhythmmethod

VB Login Script Help needed

by rhythmmethod . Updated 19 years, 8 months ago

Please forgive me, but i’m extremely new to VBScript. I need to write a login script to map drives based on group membership in a windows 2003 AD Domain. I’ve found numerous examples all over the net, but none of them has seemed to work properly for me.

Here is one of the examples that i’ve been playing with:

Const ACCOUNTING_GROUP = “cn=accounting”
Const IT_GROUP = “cn=information technology”

Dim wshNetwork, objUser, CurrentUser, strGroup, fso

Set wshNetwork = CreateObject(“WScript.Network”)
Set fso = CreateObject (“Scripting.FileSystemObject”)
Set objNetwork = CreateObject(“ADSystemInfo”)
Set CurrentUser = GetObject(“LDAP://” & objNetwork.UserName)
strGroup = LCase(Join(objNetwork.UserName))

‘ACCOUNTING
If InStr(wshNetwork.UserDomain,wshNetwork.UserName, “ACCOUNTING_GROUP”) Then
wshNetwork.MapNetworkDrive “V:”, “\\SERVER\ACCOUNTING_SHARE”
wshNetwork.MapNetworkDrive “Z:”, “\\SERVER\ACCOUNTING_SHARE2”
wshNetwork.AddWindowsPrinterConnection “\\PrintServer\EngLaser”
wshNetwork.AddWindowsPrinterConnection “\\PrintServer\Plotter”
wshNetwork.SetDefaultPrinter “\\PrintServer\EngLaser”
End If

‘INFORMATION TECHNOLOGY
If InStr(wshNetwork.UserDomain,wshNetwork.UserName, “IT_GROUP”) Then
wshNetwork.MapNetworkDrive “V:”, “\\SERVER\IT_SHARE”
wshNetwork.MapNetworkDrive “Z:”, “\\SERVER\IT_SHARE2”
wshNetwork.AddWindowsPrinterConnection “\\PrintServer\FinLaser”
wshNetwork.SetDefaultPrinter “\\PrintServer\FinLaser”
End If

I can get it to map to the first set of drives (information technology group), but whenever i assign the script to a user in another group other than information technology (ie: accounting), it still maps to the IT shares.

Should i be using a sub for each groups drive mappings? If so, what ‘if’ statements would be needed, and how would they look in order to call the appropriate sub?

Hopefully i’ve given enough information. If i’m missing anything, let me know.

Any help would be greatly appreciated.

Thanks.

This discussion is locked

All Comments