Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: Windows Server » microsoft.public.windows.server.scripting
Thread: nEED HELP WITH LOGIN SCRIPT

HTVi
TV Discussion Newsgroups

nEED HELP WITH LOGIN SCRIPT
Zzzzzz <iscubafanatic[ at ]hotmail.com> 5/7/2007 4:44:50 PM
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

Re: nEED HELP WITH LOGIN SCRIPT
"Al Dunbar" <AlanDrub[ at ]hotmail.com.nospaam> 5/8/2007 2:33:00 AM
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:

[Quoted Text]
> ' 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
>


Re: nEED HELP WITH LOGIN SCRIPT
"Richard Mueller [MVP]" <rlmueller-nospam[ at ]ameritech.nospam.net> 5/9/2007 12:13:30 AM
Also, the use of "On Error Resume Next" makes it very difficult to
troubleshoot. As Al suggests, strGroup may be the problem. The statement:

strGroup = LCase(Join(CurrentUser.MemberOf))

will raise an error unless the user is a direct member of at least 2 groups,
not counting the "primary" group (usually "Domain Users"). The Join function
expects an array, otherwise a type mismatch error is raised and strGroup
will be blank. One solution would be code similar to:

arrGroup = CurrentUser.memberOf
If IsEmpty(arrGroup) Then
strGroup = ""
ElseIf (TypeName(arrGroup) = "String") Then
strGroup = LCase(arrGroup)
Else
strGroup = LCase(Join(arrGroup))
End If

I would recommend removing the "On Error Resume Next", then running the
script after logon to see if there are any error messages. Unless all users
are direct members of at least 2 groups in addition to their "primary"
group, you will need to either modify how you retrieve the value of strGroup
as above, or find another method to check group membership. I personally
like using the IsMember method of the group object if I am not concerned
about nested group memberships. For example:

Set objGroup = GetObject("LDAP://cn=TestGroupA,ou=Sales,dc=MyDomain,dc=com")
If (objGroup.IsMember(CurrentUser.AdsPath) = True) Then
objNetwork.AddWindowsPrinterConnection strUNCPrinter1
objNetwork.SetDefaultPrinter strUNCPrinter2
End If

This requires binding to the group objects, but makes group checking easy.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

"Al Dunbar" <AlanDrub[ at ]hotmail.com.nospaam> wrote in message
news:%23CJ24wRkHHA.4516[ at ]TK2MSFTNGP03.phx.gbl...

[Quoted Text]
> 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
>>
>
>


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen