> It is a little hard to say for sure, as you do not specifically mention
> what error messages (if any) or displayed. If it is failing to execute ANY
> of the commands contained in conditional blocks like this one:
>
>> ' Extra printers for specific groups
>> If InStr(strGroup, LCase(HRPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>
> Then I would suspect that the strGroup variable does not contain what you
> expect it would. I would suggest you insert some code to display this. I
> haven't used that particular method for testing group membership, however,
> I suspect that the .memberof property will return only those groups in
> which the user is a direct member. If the membership comes through
> membership in another group that is a member of the group you are testing,
> then that may not be reported.
>
> Perhaps the best resource for what you want is Richard Mueller's site:
>
>
http://www.rlmueller.net/freecode1.htm>
>
> /Al
>
> "Zzzzzz" <iscubafanatic[ at ]hotmail.com> wrote in message
> news:1178556290.632211.4540[ at ]e65g2000hsc.googlegroups.com...
>> Hi,
>>
>> The following login script doesn't want to add drives and printers
>> based on membership, the static drives and printers work but when it
>> comes to querying the AD it's not working. I am aware that not all of
>> the printer objects are defined at this stage.
>>
>> I am also wondering if there is a more efficient way of doing this,
>> plus if as user belongs to more than one printer group will it still
>> join them?
>>
>> Option Explicit
>> Dim objNetwork, objUser, CurrentUser
>> Dim strGroup
>> Dim strDriveLetter1, strDriveLetter2, strDriveLetter3,
>> strDriveLetter4, strDriveLetter5
>> Dim strRemotePath1, strRemotePath2, strRemotePath3, strRemotePath4,
>> strRemotePath5, strRemotePath6, strRemotePath7, strRemotePath8,
>> strRemotePath9, strRemotePath10, strRemotePath11, strRemotePath12,
>> strRemotePath13, strRemotePath14
>> Dim strUNCPrinter1, strUNCPrinter2, strUNCPrinter3, strUNCPrinter4,
>> strUNCPrinter5, strUNCPrinter6, strUNCPrinter7, strUNCPrinter8,
>> strUNCPrinter9, strUNCPrinter10, strUNCPrinter11, strUNCPrinter12,
>> strUNCPrinter13, strUNCPrinter14, strUNCPrinter15, strUNCPrinter16,
>> strUNCPrinter17, strUNCPrinter18, strUNCPrinter19
>> Dim bForce, bUpdateProfile
>>
>> on error resume next
>>
>> strDriveLetter1 = "Q:"
>> strDriveLetter2 = "R:"
>> strDriveLetter3 = "S:"
>>
>> strRemotePath1 = "\\rdcits01\Share"
>> strRemotePath2 = "\\rdcits01\ISO"
>> strRemotePath3 = "\\rdcits01\AP-Share"
>> strRemotePath4 = "\\rdcits01\AR-Share"
>> strRemotePath5 = "\\rdcits01\CS-Share"
>> strRemotePath6 = "\\rdcits01\DC-Share"
>> strRemotePath7 = "\\rdcits01\HR-Share"
>> strRemotePath8 = "\\rdcits01\HT-Share"
>> strRemotePath9 = "\\rdcits01\FI-Share"
>> strRemotePath10 = "\\rdcits01\IP-Share"
>> strRemotePath11 = "\\rdcits01\IT-Share"
>> strRemotePath12 = "\\rdcits01\MK-Share"
>> strRemotePath13 = "\\rdcits01\RT-Share"
>> strRemotePath14 = "\\rdcits01\SA-Share"
>>
>> strUNCPrinter1 = "\\rdcits01\RDCOSP01"
>> strUNCPrinter2 = "\\rdcits01\RDCOSP02"
>> strUNCPrinter3 = "\\rdcits01\RDCOSP03"
>> strUNCPrinter4 = "\\rdcits01\RDCOSP04"
>> strUNCPrinter5 = "\\rdcits01\"
>> strUNCPrinter6 = "\\rdcits01\"
>> strUNCPrinter7 = "\\rdcits01\"
>> strUNCPrinter8 = "\\rdcits01\"
>> strUNCPrinter9 = "\\rdcits01\"
>> strUNCPrinter10 = "\\rdcits01\"
>> strUNCPrinter11 = "\\rdcits01\"
>> strUNCPrinter12 = "\\rdcits01\"
>> strUNCPrinter13 = "\\rdcits01\"
>> strUNCPrinter14 = "\\rdcits01\"
>> strUNCPrinter15 = "\\rdcits01\"
>> strUNCPrinter16 = "\\rdcits01\"
>> strUNCPrinter16 = "\\rdcits01\"
>> strUNCPrinter17 = "\\rdcits01\"
>> strUNCPrinter18 = "\\rdcits01\"
>> strUNCPrinter19 = "\\rdcits01\"
>>
>>
>> ' Initialise Groups with Const
>> Const HRFileGroup = "cn=hrfileaccess"
>> Const APFileGroup = "cn=apfileaccess"
>> Const ARFileGroup = "cn=arfileaccess"
>> Const CSFileGroup = "cn=csfileaccess"
>> Const FIFileGroup = "cn=fifileaccess"
>> Const HTFileGroup = "cn=htfileaccess"
>> Const IPFileGroup = "cn=ipfileaccess"
>> Const ITFileGroup = "cn=itfileaccess"
>> Const MKFileGroup = "cn=mkfileaccess"
>> Const RTFileGroup = "cn=rtfileaccess"
>> Const SAFileGroup = "cn=safileaccess"
>> Const DCFileGroup = "cn=dcfileaccess"
>> Const HRPrinterGroup = "cn=hrprinters"
>> Const APPrinterGroup = "cn=apprinters"
>> Const ARrPrinterGroup = "cn=arprinters"
>> Const CSPrinterGroup = "cn=csprinters"
>> Const FIPrinterGroup = "cn=fiprinters"
>> Const HTPrinterGroup = "cn=htprinters"
>> Const IPPrinterGroup = "cn=ipprinters"
>> Const ITPrinterGroup = "cn=itprinters"
>> Const MKPrinterGroup = "cn=mkprinters"
>> Const RTPrinterGroup = "cn=rtprinters"
>> Const SAPrinterGroup = "cn=saprinters"
>> Const DCPrinterGroup = "cn=dcprinters"
>>
>> ' Create objects and extract strGroup values
>> Set objNetwork = CreateObject("WScript.Network")
>> Set objUser = CreateObject("ADSystemInfo")
>> Set CurrentUser = GetObject("LDAP://" & objUser.UserName)
>> strGroup = LCase(Join(CurrentUser.MemberOf))
>> bForce = "true"
>> bUpdateProfile = "true"
>>
>> ' Removes all network drives
>> objNetwork.RemoveNetworkDrive strDriveLetter1, bForce, bUpdateProfile
>> objNetwork.RemoveNetworkDrive strDriveLetter2, bForce, bUpdateProfile
>> objNetwork.RemoveNetworkDrive strDriveLetter3, bForce, bUpdateProfile
>>
>> ' Removes all printers
>> objNetwork.RemovePrinterConnection strUNCPrinter1, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter2, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter3, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter4, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter5, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter6, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter7, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter8, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter9, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter10, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter11, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter12, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter13, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter14, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter15, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter16, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter17, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter18, bForce,
>> bUpdateProfile
>> objNetwork.RemovePrinterConnection strUNCPrinter19, bForce,
>> bUpdateProfile
>>
>> ' Adds printers that are available for all users
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter2
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter3
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter4
>>
>>
>> ' Extra printers for specific groups
>> If InStr(strGroup, LCase(HRPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>>
>> If InStr(strGroup, LCase(APPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>>
>> If InStr(strGroup, LCase(ARPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>>
>> If InStr(strGroup, LCase(CSPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>>
>> If InStr(strGroup, LCase(FIPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>>
>> If InStr(strGroup, LCase(HTPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>>
>> If InStr(strGroup, LCase(IPPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>>
>> If InStr(strGroup, LCase(ITPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter1
>> End If
>>
>> If InStr(strGroup, LCase(MKPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>>
>> If InStr(strGroup, LCase(SAPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>>
>> If InStr(strGroup, LCase(DCPrinterGroup)) Then
>> objNetwork.AddWindowsPrinterConnection strUNCPrinter1
>> objNetwork.SetDefaultPrinter strUNCPrinter2
>> End If
>>
>> ' Setting all network drives that are available for all users
>> objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1
>> objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2
>>
>> ' Adds drives for specific groups
>> if InStr(strGroup, LCase(APFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3
>> End If
>>
>> If InStr(strGroup, LCase(ARFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath4
>> End If
>>
>> If InStr(strGroup, LCase(CSFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath5
>> End If
>>
>> If InStr(strGroup, LCase(DCFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath6
>> End If
>>
>> If InStr(strGroup, LCase(HRFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath7
>> End If
>>
>> If InStr(strGroup, LCase(HTFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath8
>> End If
>>
>> If InStr(strGroup, LCase(FIFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath9
>> End If
>>
>> If InStr(strGroup, LCase(IPFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath10
>> End If
>>
>> If InStr(strGroup, LCase(ITFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath11
>> End If
>>
>> If InStr(strGroup, LCase(MKFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath12
>> End If
>>
>> If InStr(strGroup, LCase(RTFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath13
>> End If
>>
>> If InStr(strGroup, LCase(SAFileGroup)) Then
>> objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath14
>> End If
>>
>> Set objNetwork = Nothing
>> Set objUser = Nothing
>> Set CurrentUser = Nothing
>> Set strGroup = Nothing
>> Set strDriveLetter1 = Nothing
>> Set strDriveLetter2 = Nothing
>> Set strDriveLetter3 = Nothing
>> Set strDriveLetter4 = Nothing
>> Set strDriveLetter5 = Nothing
>> Set strRemotePath1 = Nothing
>> Set strRemotePath2 = Nothing
>> Set strRemotePath3 = Nothing
>> Set strRemotePath4 = Nothing
>> Set strRemotePath5 = Nothing
>> Set strRemotePath6 = Nothing
>> Set strRemotePath7 = Nothing
>> Set strRemotePath8 = Nothing
>> Set strRemotePath9 = Nothing
>> Set strRemotePath10 = Nothing
>> Set strRemotePath11 = Nothing
>> Set strRemotePath12 = Nothing
>> Set strRemotePath13 = Nothing
>> Set strRemotePath14 = Nothing
>> Set strUNCPrinter1 = Nothing
>> Set strUNCPrinter2 = Nothing
>> Set strUNCPrinter3 = Nothing
>> Set strUNCPrinter4 = Nothing
>> Set strUNCPrinter5 = Nothing
>> Set strUNCPrinter6 = Nothing
>> Set strUNCPrinter7 = Nothing
>> Set strUNCPrinter8 = Nothing
>> Set strUNCPrinter9 = Nothing
>> Set strUNCPrinter10 = Nothing
>> Set strUNCPrinter11 = Nothing
>> Set strUNCPrinter12 = Nothing
>> Set strUNCPrinter13 = Nothing
>> Set strUNCPrinter14 = Nothing
>> Set strUNCPrinter15 = Nothing
>> Set strUNCPrinter16 = Nothing
>> Set strUNCPrinter17 = Nothing
>> Set strUNCPrinter18 = Nothing
>> Set strUNCPrinter19 = Nothing
>> Set bForce = Nothing
>> Set bUpdateProfile = Nothing
>>
>> WScript.Quit
>>
>
>