Jason
Wed Jun 25 07:57:02 PDT 2008
"Richard Mueller [MVP]" wrote:
>
> "Jason" <Jason@discussions.microsoft.com> wrote in message
> news:371E5FDA-E238-490F-A44F-479A42E35E34@microsoft.com...
> >
> >
> > "Pegasus (MVP)" wrote:
> >
> >>
> >> "Jason" <Jason@discussions.microsoft.com> wrote in message
> >> news:171E6217-5AEA-42F9-8156-81E46510D4BC@microsoft.com...
> >> > Hi
> >> >
> >> > Ok here is the situation....
> >> >
> >> > I have a .vbs login script in the user portion of group policy object
> >> > that
> >> > maps drives to the user account depending on the groups they are in.
> >> > There's
> >> > no actual problem with the script. It does what it should do however on
> >> > 2
> >> > machines it simply will not map the drives.
> >> >
> >> > THe script is written to delete any mapped drive the user may have
> >> > before
> >> > mapping the drives set out by the script.
> >> >
> >> > On these two machines, the deletion takes place but the mapping does
> >> > not.
> >> >
> >> > Now here is the odd part.
> >> >
> >> > If I run the script directly on the machine it works fine. If I log in
> >> > to
> >> > another machine with the same user it works fine so the problem seems
> >> > to
> >> > be
> >> > specifically with these two computers.
> >> >
> >> > Does anyone have an idea of what could be causing this?
> >> >
> >> > Thanks
> >> >
> >> > Jason
> >>
> >> Here are a couple of suggestions:
> >> - Get the script to pause after mapping the share so that YOU
> >> can see what's going on.
> >> - Post your script so that WE can see what you're doing.
> >> And, of course, remove all "on error" statements from your script!
> >>
> >>
> >
> > Hi Pegasus, thanks for the reply. I am testing the script with the pauses
> > you suggested but while I do that, here is the script I am using.
> >
> > '-----------------------------------------------------------------
> > 'DELETES NETWORKED DRIVES THE USER MAY HAVE SET UP.
> > '-----------------------------------------------------------------
> >
> > Next
> >
> > Set objNetwork = CreateObject("Wscript.Network")
> >
> > Set colDrives = objNetwork.EnumNetworkDrives
> >
> > For i = 0 to colDrives.Count-1 Step 2
> > objNetwork.RemoveNetworkDrive colDrives.Item(i)
> >
> >
> > Next
> >
> > '-----------------------------------------------------------------
> > 'MAPS TO THE SECURE USER FOLDER BASED ON THE USERNAME
> > '-----------------------------------------------------------------
> >
> > Set objSysInfo = CreateObject("ADSystemInfo")
> >
> > strUser = objSysInfo.UserName
> > Set objUser = GetObject("LDAP://" & strUser)
> >
> > strUserName = objUser.samAccountName
> >
> > strOUPath = objUser.Parent
> > arrContainers = Split(strOUPath, ",")
> > arrOU = Split(arrContainers(0), "=")
> > strOU = arrOU(1)
> >
> > strDrive = "\\server02\Secure Folder - "& strUserName
> >
> > Set objNetwork = CreateObject("Wscript.Network")
> > objNetwork.MapNetworkDrive "A:", strDrive
> >
> >
> > '-----------------------------------------------------------------
> > 'MAPS THE GROUP DRIVES
> > '-----------------------------------------------------------------
> >
> > 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 "mycompany Staff"
> > objNetwork.MapNetworkDrive "G:", "\\SERVER02\mycompany General
> > Shared Drive"
> >
> >
> > Case "Domain Admins"
> > objNetwork.MapNetworkDrive "Y:", "\\SERVER02\Network
> > Administrator"
> > objNetwork.MapNetworkDrive "W:", "\\Server02\f$"
> >
> >
> > Case "mycompany Finance Staff"
> > objNetwork.MapNetworkDrive "T:", "\\SERVER02\Finance"
> > objNetwork.MapNetworkDrive "X:", "\\SERVER02\Sage"
> >
> > Case "mycompany Sales Staff"
> > objNetwork.MapNetworkDrive "U:", "\\SERVER02\Sales & Marketing"
> >
> > Case "mycompany HR & Compliance staff"
> > objNetwork.MapNetworkDrive "S:", "\\SERVER02\Company Secretary"
> > objNetwork.MapNetworkDrive "R:", "\\SERVER02\Compliance"
> > objNetwork.MapNetworkDrive "Q:", "\\SERVER02\Human Resources"
> > objNetwork.MapNetworkDrive "P:", "\\SERVER02\mycompany Board"
> > objNetwork.MapNetworkDrive "O:", "\\SERVER02\Operations"
> > objNetwork.MapNetworkDrive "N:", "\\SERVER02\Audit Comittee"
> >
> > Case "mycompany Board Staff"
> > objNetwork.MapNetworkDrive "V:", "\\SERVER02\mycompany Board"
> > objNetwork.MapNetworkDrive "M:", "\\SERVER02\Audit Comittee"
> >
> > Case "mycompany Affiliate Staff"
> > objNetwork.MapNetworkDrive "L:", "\\SERVER02\Affiliates"
> >
> > Case "Sage"
> > objNetwork.MapNetworkDrive "X:", "\\SERVER02\Sage"
> >
> > Case "mycompany legal Staff"
> > objNetwork.MapNetworkDrive "K:", "\\SERVER02\Legal"
> >
> > Case "Rael"
> > objNetwork.MapNetworkDrive "T:", "\\SERVER02\Finance"
> >
> > Case "Paul"
> > objNetwork.MapNetworkDrive "E:", "\\Server02\mycompany General
> > Shared Drive\site_enhancements\WebsiteImages"
> >
> >
> > End Select
> > Next
> >
> >
>
> There seems to a problem that halts the script after the code the removes
> the mappings. A potential problem is that memberOf may not be a collection
> in the "For Each" loop. This happens if the user is a member of less than
> two groups (not counting the "primary" group, which is usually "Domain
> Users"). An error is raised if the user is a member of no groups or one
> group (besides "Domain Users"). I would suggest something similar to:
> ===========
> On Error Resume Next
> arrGroups = objUser.GetEx("memberOf")
> If (Err.Number = 0) Then
> On Error GoTo 0
> For Each strGroup In arrGroups
> ' Code for each group.
> ' ...
> Next
> End If
> On Error GoTo 0
> ========
> For more on this, see this link:
>
>
http://www.rlmueller.net/MemberOf.htm
>
> Actually, since you bind to each group object, you may as well use the
> Groups method of the user object and avoid the complications. For example, I
> would suggest:
>
> For each objGroup in objUser.Groups
> Select Case objGroup.cn
> Case "staff"
> ' ...
> Case "Domain Admins"
> ' ...
> End Select
> Next
> ====
> If you are not using strOU, I would remove the code that determines the
> value of this. That code looks OK, but is not fool proof.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -
http://www.rlmueller.net
> --
>
>
>
How would that explain the fact the script works perfectly when the same
user logs on to a different PC. Given the user account is in the same number
of groups etc?
I am trying your script suggestions as you speak but I'm still puzzled about
that it works fine on other machines.