Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

trouble with logon script

36 views
Skip to first unread message

Bret Snipes

unread,
Sep 25, 2007, 11:50:00 AM9/25/07
to
Guys & Gals could I please get some help with the following script. I found
it on the web and it works sometimes and other times it doesn't. I use it
to map drives based on group member ship. We have a W2K sp4 domain. I am
currently getting the following message:
Windows Script Host
Script: \\server\netlogon\logon.vbs
Line: 10
Char: 1
Error: Object not a collection
Code: 800A01C3
Source: Microsoft VBScript runtime error

Here is the script (please not server & share names are not actual) and in
the script there is a blank line BEFORE "On Error Resume Next"


' On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")

strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)

For Each strGroup in objUser.MemberOf
strGroupPath = "LDAP://" & strGroup
Set objGroup = GetObject(strGroupPath)
strGroupName = objGroup.CN

Select Case strGroupName
Case "MVCS_StaffFacultyAdmin"
objNetwork.MapNetworkDrive "R:", \\server\share01
objNetwork.MapNetworkDrive "Q:", \\server\share02
objNetwork.MapNetworkDrive "T:", \\server\share03
objNetwork.MapNetworkDrive "x:", \\server\share04

Case "MVCS_Library"
objNetwork.MapNetworkDrive "R:", \\server\share01
objNetwork.MapNetworkDrive "Q:", \\server\share02

Case "MVCS_Quickbooks"
objNetwork.MapNetworkDrive "I:", \\server\share05

Case "MVCS_Teachers"
objNetwork.MapNetworkDrive "S:", \\server\share06

Case "MVCS_Volunteer"
objNetwork.MapNetworkDrive "Q:", \\server\share02
objNetwork.MapNetworkDrive "T:", \\server\share03

End Select
Next

Your help is greatly appreciated
Bret


Pegasus (MVP)

unread,
Sep 25, 2007, 12:01:23 PM9/25/07
to

"Bret Snipes" <tech...@newsgroup.nospam> wrote in message
news:OuzHLv4$HHA....@TK2MSFTNGP03.phx.gbl...

Surround your share names with double quotes, e.g.

Bret Snipes

unread,
Sep 25, 2007, 12:45:00 PM9/25/07
to
my bad. In the actual script the share names have double quotes.


"Pegasus (MVP)" <I....@fly.com> wrote in message
news:%23QAeS14$HHA....@TK2MSFTNGP06.phx.gbl...

Richard Mueller [MVP]

unread,
Sep 25, 2007, 3:09:02 PM9/25/07
to

"Bret Snipes" <tech...@newsgroup.nospam> wrote in message
news:OuzHLv4$HHA....@TK2MSFTNGP03.phx.gbl...

The code you reference has a flaw. This is so common that I have a page on
my web site explaining in detail:

http://www.rlmueller.net/MemberOf.htm

Basically, any code using the memberOf attribute must account for the 3
possible situations: where memberOf is Empty, memberOf has one DN in which
case it is retrieved as a String, and memberOf has more than one DN in which
case it is retrieved as a variant array "Variant()". The "For Each"
statement expects an array, so raises an error unless the user is a direct
member of at least 2 groups (not counting the "primary" group which is never
included in memberOf).

I suggest a few alternatives in the link.

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


0 new messages