Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Map Drive Login Script Issue

Windows Server Help


Reply
 
Thread Tools Search this Thread
  #1  
Old 25-06-2008
Jason
 
Posts: n/a
Map Drive Login Script Issue

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

Reply With Quote
  #2  
Old 25-06-2008
Pegasus \(MVP\)
 
Posts: n/a
Re: Map Drive Login Script Issue


"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!


Reply With Quote
  #3  
Old 25-06-2008
Jason
 
Posts: n/a
Re: Map Drive Login Script Issue



"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


Reply With Quote
  #4  
Old 25-06-2008
Jason
 
Posts: n/a
Re: Map Drive Login Script Issue

Ignore the first Next in the script, that is a bad copy and paste job!

"Jason" wrote:

>
>
> "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
>
>

Reply With Quote
  #5  
Old 25-06-2008
Richard Mueller [MVP]
 
Posts: n/a
Re: Map Drive Login Script Issue


"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
--


Reply With Quote
  #6  
Old 25-06-2008
Jason
 
Posts: n/a
Re: Map Drive Login Script Issue



"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.
Reply With Quote
  #7  
Old 25-06-2008
Jason
 
Posts: n/a
Re: Map Drive Login Script Issue

In addition, after further testing it would appear that script isnt running
at all on the machine in question. There are a bunch of scripts in the same
GPO which I know are all running fine.

I set a MsgBox at the start & end of the Drive Map Script and these were not
returned to the screen indicating it didnt run.

Baffled! :(
Reply With Quote
  #8  
Old 25-06-2008
Richard Mueller [MVP]
 
Posts: n/a
Re: Map Drive Login Script Issue


"Jason" <Jason@discussions.microsoft.com> wrote in message
news:61179FBD-E37E-4489-8AEA-A43E5C99B148@microsoft.com...
>

....

>
> 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.


You are correct. I assume when you say the script works fine when run on the
computer after logon, that you mean when run by the problem user. If it
works for all users as a logon script on one computer, works for some but
not all users as a logon script a problem computer, and works for all on the
problem computer after logon, then the only thing I can think of is a timing
issue (which doesn't seem likely). I also assume the same script is used in
all cases (I note that the group name comparisions are case sensitive, for
example).

If you do not have "On Error Resume Next" you should either see an error
message (which will indicate the line number in the script telling you
exactly which statement raised the error), or the script has run as if the
user is not a member of any of the specified groups. For testing I would
reduce the script to just what is necessary. Perhaps (I added comments, also
watch for line wrapping):
==========
Option Explicit

' I use Option Explicit and declare all variables
' to make troubleshooting easier.
Dim objNetwork, colDrives, i
Dim objSysInfo, objUser, strUser, strUserName
Dim strDrive, objGroup, strGroupName

Set objNetwork = CreateObject("Wscript.Network")
Set colDrives = objNetwork.EnumNetworkDrives
' Technically, you should enumerate from 0 to count less 2.
For i = 0 to colDrives.Count - 2 Step 2
' Remove even if mapping is in use and even if persistent.
objNetwork.RemoveNetworkDrive colDrives.Item(i), True, True
Next

' Temporary message.
Call MsgBox("Existing mappings removed")

' Note that this will fail if user is not authenticated to a domain.
Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
strUserName = objUser.sAMAccountName

strDrive = "\\server02\Secure Folder - " & strUserName
' I wonder if this could raise an error, since A: might not be legal.
objNetwork.MapNetworkDrive "A:", strDrive

' Temporary message.
Call MsgBox("Drive A: mapped")

For each objGroup in objUser.Groups
' Make group names case insensitive.
strGroupName = LCase(objGroup.cn)
' Temporary message.
Call MsgBox("Group: " & strGroupName)
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
' Temporary message.
Call MsgBox("Done")
========
And of course do not use "On Error Resume Next". If any of the paths are not
found, an error should be raised when they attempt to map to it. Possibly,
the UNC path is not available from some computers (or the user lacks
permission), but I would expect the same problem after logon (assuming the
same user runs the script).

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


Reply With Quote
  #9  
Old 25-06-2008
Richard Mueller [MVP]
 
Posts: n/a
Re: Map Drive Login Script Issue


"Jason" <Jason@discussions.microsoft.com> wrote in message
news:E08F0800-45A6-4204-8C34-0B959F0F5436@microsoft.com...
> In addition, after further testing it would appear that script isnt
> running
> at all on the machine in question. There are a bunch of scripts in the
> same
> GPO which I know are all running fine.
>
> I set a MsgBox at the start & end of the Drive Map Script and these were
> not
> returned to the screen indicating it didnt run.
>
> Baffled! :(


This helps a great deal. We know the problem is probably not in the script.
For some reason the policy is not being applied to these users on the
problem computers.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


Reply With Quote
  #10  
Old 26-06-2008
Jason
 
Posts: n/a
Re: Map Drive Login Script Issue



"Richard Mueller [MVP]" wrote:

>
> "Jason" <Jason@discussions.microsoft.com> wrote in message
> news:61179FBD-E37E-4489-8AEA-A43E5C99B148@microsoft.com...
> >

> ....
>
> >
> > 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.

>
> You are correct. I assume when you say the script works fine when run on the
> computer after logon, that you mean when run by the problem user. If it
> works for all users as a logon script on one computer, works for some but
> not all users as a logon script a problem computer, and works for all on the
> problem computer after logon, then the only thing I can think of is a timing
> issue (which doesn't seem likely). I also assume the same script is used in
> all cases (I note that the group name comparisions are case sensitive, for
> example).
>
> If you do not have "On Error Resume Next" you should either see an error
> message (which will indicate the line number in the script telling you
> exactly which statement raised the error), or the script has run as if the
> user is not a member of any of the specified groups. For testing I would
> reduce the script to just what is necessary. Perhaps (I added comments, also
> watch for line wrapping):
> ==========


> ========
> And of course do not use "On Error Resume Next". If any of the paths are not
> found, an error should be raised when they attempt to map to it. Possibly,
> the UNC path is not available from some computers (or the user lacks
> permission), but I would expect the same problem after logon (assuming the
> same user runs the script).
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>


Ok the issue has been resolved. To be honset, I'm unable to say what caused
the issue but my fix works and at the moment that's all that matters.

Basically I have a number of scripts that run. I have a main one that does
many things and a few others. The drive map script was a seperate script.

After much testing, I eventually added the code of the drive map script to
the end of the main script and for some reason it worked on the two machines
that had problems.

so... /shrug...

thanks for all the help though.

Jason


Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Windows Server Help
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Map Drive Login Script Issue"
Thread Thread Starter Forum Replies Last Post
Calling login Script Chicago2010 Software Development 1 13-08-2010 12:07 PM
WAP login script in php Steinbach Software Development 3 14-04-2009 09:22 AM
Login Script to handle Persistent Drive Mapping Mike Bailey Windows Server Help 2 11-09-2008 11:19 AM
to add username & password into my login.cmd - login script sphilip Windows Server Help 4 05-03-2008 11:04 PM
Startup Script or Login Script ?? WANNABE Active Directory 5 22-12-2006 07:44 PM


All times are GMT +5.5. The time now is 04:06 PM.