Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Creating logon scripts - the script will map different sets of drivesdepending on the security grp the user is in.

Reply
 
Old 08-16-2009   #1 (permalink)
RBoyle


 
 

Creating logon scripts - the script will map different sets of drivesdepending on the security grp the user is in.

I'm trying to create a logon scripts that will map my users network
drives based on a certain security group that they are in:

I'm in the testing stage so far and below is what I have (I'm testing
against our IT security group right now). When I put this in place
its not mapping the drives listed -- could anyone say why and possibly
give me the change I need to do so that those three drives will map.

Here is my vbscript -- thanks for the help in advance:

Ryan

----------------

Const IT_GROUP = "cn=IT$ DEPARTMENT (R & W)"

Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)


strGroups = LCase(Join(CurrentUser.MemberOf))

If InStr(strGroups, IT_Group) Then

wshNetwork.RemoveNetworkDrive "I:"
wshNetwork.RemoveNetworkDrive "Z:"
wshNetwork.RemoveNetworkDrive "K:"

wshNetwork.MapNetworkDrive "I:", "\\netwincp\it$\"
wshNetwork.MapNetworkDrive "Z:", "\\netwincp\accounting\"
wshNetwork.MapNetworkDrive "K:", "\\netwincp\kdrive\"

End If


My System SpecsSystem Spec
Old 08-16-2009   #2 (permalink)
Al Dunbar


 
 

Re: Creating logon scripts - the script will map different sets of drives depending on the security grp the user is in.


"RBoyle" <ryan.j.boyle.cpg@xxxxxx> wrote in message
news:e619bc0e-0fd5-4c06-a72f-9ae8f05334ae@xxxxxx
Quote:

> I'm trying to create a logon scripts that will map my users network
> drives based on a certain security group that they are in:
>
> I'm in the testing stage so far and below is what I have (I'm testing
> against our IT security group right now). When I put this in place
> its not mapping the drives listed -- could anyone say why and possibly
> give me the change I need to do so that those three drives will map.
>
> Here is my vbscript -- thanks for the help in advance:
>
> Ryan
>
> ----------------
>
> Const IT_GROUP = "cn=IT$ DEPARTMENT (R & W)"
>
> Set wshNetwork = CreateObject("WScript.Network")
> Set ADSysInfo = CreateObject("ADSystemInfo")
> Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
>
>
> strGroups = LCase(Join(CurrentUser.MemberOf))
I'd suggest displaying this value to see what it is:

wscript.echo strGroups
Quote:

> If InStr(strGroups, IT_Group) Then
I'd suggest changing the above statement to the one just below to avoid
upper/lower case mismatches:

If InStr(1, strGroups, IT_Group, 1) Then
Quote:

> wshNetwork.RemoveNetworkDrive "I:"
> wshNetwork.RemoveNetworkDrive "Z:"
> wshNetwork.RemoveNetworkDrive "K:"
>
> wshNetwork.MapNetworkDrive "I:", "\\netwincp\it$\"
> wshNetwork.MapNetworkDrive "Z:", "\\netwincp\accounting\"
> wshNetwork.MapNetworkDrive "K:", "\\netwincp\kdrive\"
>
> End If
/Al


My System SpecsSystem Spec
Old 08-16-2009   #3 (permalink)
Richard Mueller [MVP]


 
 

Re: Creating logon scripts - the script will map different sets of drives depending on the security grp the user is in.


"Al Dunbar" <alandrub@xxxxxx> wrote in message
news:OftIlkqHKHA.4004@xxxxxx
Quote:

>
> "RBoyle" <ryan.j.boyle.cpg@xxxxxx> wrote in message
> news:e619bc0e-0fd5-4c06-a72f-9ae8f05334ae@xxxxxx
Quote:

>> I'm trying to create a logon scripts that will map my users network
>> drives based on a certain security group that they are in:
>>
>> I'm in the testing stage so far and below is what I have (I'm testing
>> against our IT security group right now). When I put this in place
>> its not mapping the drives listed -- could anyone say why and possibly
>> give me the change I need to do so that those three drives will map.
>>
>> Here is my vbscript -- thanks for the help in advance:
>>
>> Ryan
>>
>> ----------------
>>
>> Const IT_GROUP = "cn=IT$ DEPARTMENT (R & W)"
>>
>> Set wshNetwork = CreateObject("WScript.Network")
>> Set ADSysInfo = CreateObject("ADSystemInfo")
>> Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
>>
>>
>> strGroups = LCase(Join(CurrentUser.MemberOf))
>
> I'd suggest displaying this value to see what it is:
>
> wscript.echo strGroups
>
Quote:

>> If InStr(strGroups, IT_Group) Then
>
> I'd suggest changing the above statement to the one just below to avoid
> upper/lower case mismatches:
>
> If InStr(1, strGroups, IT_Group, 1) Then
>
Quote:

>> wshNetwork.RemoveNetworkDrive "I:"
>> wshNetwork.RemoveNetworkDrive "Z:"
>> wshNetwork.RemoveNetworkDrive "K:"
>>
>> wshNetwork.MapNetworkDrive "I:", "\\netwincp\it$\"
>> wshNetwork.MapNetworkDrive "Z:", "\\netwincp\accounting\"
>> wshNetwork.MapNetworkDrive "K:", "\\netwincp\kdrive\"
>>
>> End If
>
> /Al
>
Also, when you use the Join function, you also use the LCase function, which
makes all of the group Distinguished Names lower case. However, your
constant defines IT_Group as mixed case. The value assigned to IT_Group
should be all lower case. I think Al's optional third parameter passed to
the InStr function makes the comparison case insensitive. If that's the
case, then you can use mixed case.

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


My System SpecsSystem Spec
Old 08-17-2009   #4 (permalink)
Stefan Kanthak


 
 

Re: Creating logon scripts - the script will map different sets of drives depending on the security grp the user is in.

"Al Dunbar" <alandrub@xxxxxx> wrote:
Quote:

>
> "RBoyle" <ryan.j.boyle.cpg@xxxxxx> wrote in message
> news:e619bc0e-0fd5-4c06-a72f-9ae8f05334ae@xxxxxx
Quote:

>> I'm trying to create a logon scripts that will map my users network
>> drives based on a certain security group that they are in:
>>
>> I'm in the testing stage so far and below is what I have (I'm testing
>> against our IT security group right now). When I put this in place
>> its not mapping the drives listed -- could anyone say why and possibly
>> give me the change I need to do so that those three drives will map.
>>
>> Here is my vbscript -- thanks for the help in advance:
>>
>> Ryan
>>
>> ----------------
>>
>> Const IT_GROUP = "cn=IT$ DEPARTMENT (R & W)"
>>
>> Set wshNetwork = CreateObject("WScript.Network")
>> Set ADSysInfo = CreateObject("ADSystemInfo")
>> Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
>>
>>
>> strGroups = LCase(Join(CurrentUser.MemberOf))
Const DELIMITOR = "|"
strGroups = DELIMITOR & LCase(Join(..., DELIMITOR)) & DELIMITOR
Quote:

> I'd suggest displaying this value to see what it is:
>
> wscript.echo strGroups
>
Quote:

>> If InStr(strGroups, IT_Group) Then
>
> I'd suggest changing the above statement to the one just below to avoid
> upper/lower case mismatches:
And what about substring mismatches?
Quote:

> If InStr(1, strGroups, IT_Group, 1) Then
If InStr(1, strGroups, DELIMITOR & LCase(IT_Group) & DELIMITOR, 1) Then

Stefan

My System SpecsSystem Spec
Old 08-18-2009   #5 (permalink)
Al Dunbar


 
 

Re: Creating logon scripts - the script will map different sets of drives depending on the security grp the user is in.


"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxx> wrote in
message news:eummuPrHKHA.4432@xxxxxx
Quote:

>
> "Al Dunbar" <alandrub@xxxxxx> wrote in message
> news:OftIlkqHKHA.4004@xxxxxx
Quote:

>>
>> "RBoyle" <ryan.j.boyle.cpg@xxxxxx> wrote in message
>> news:e619bc0e-0fd5-4c06-a72f-9ae8f05334ae@xxxxxx
Quote:

>>> I'm trying to create a logon scripts that will map my users network
>>> drives based on a certain security group that they are in:
>>>
>>> I'm in the testing stage so far and below is what I have (I'm testing
>>> against our IT security group right now). When I put this in place
>>> its not mapping the drives listed -- could anyone say why and possibly
>>> give me the change I need to do so that those three drives will map.
>>>
>>> Here is my vbscript -- thanks for the help in advance:
>>>
>>> Ryan
>>>
>>> ----------------
>>>
>>> Const IT_GROUP = "cn=IT$ DEPARTMENT (R & W)"
>>>
>>> Set wshNetwork = CreateObject("WScript.Network")
>>> Set ADSysInfo = CreateObject("ADSystemInfo")
>>> Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
>>>
>>>
>>> strGroups = LCase(Join(CurrentUser.MemberOf))
>>
>> I'd suggest displaying this value to see what it is:
>>
>> wscript.echo strGroups
>>
Quote:

>>> If InStr(strGroups, IT_Group) Then
>>
>> I'd suggest changing the above statement to the one just below to avoid
>> upper/lower case mismatches:
>>
>> If InStr(1, strGroups, IT_Group, 1) Then
>>
Quote:

>>> wshNetwork.RemoveNetworkDrive "I:"
>>> wshNetwork.RemoveNetworkDrive "Z:"
>>> wshNetwork.RemoveNetworkDrive "K:"
>>>
>>> wshNetwork.MapNetworkDrive "I:", "\\netwincp\it$\"
>>> wshNetwork.MapNetworkDrive "Z:", "\\netwincp\accounting\"
>>> wshNetwork.MapNetworkDrive "K:", "\\netwincp\kdrive\"
>>>
>>> End If
>>
>> /Al
>>
>
> Also, when you use the Join function, you also use the LCase function,
> which makes all of the group Distinguished Names lower case. However, your
> constant defines IT_Group as mixed case. The value assigned to IT_Group
> should be all lower case.
LOL - I hadn't even noticed that he had used LCase!
Quote:

> I think Al's optional third parameter passed to the InStr function
> makes the comparison case insensitive.
Yes, in fact that is the function of this parameter. I had to look it up
too, as case issues are something I tend to avoid in other ways...

But one of the odd quirks here is that, while it follows what is normally
the second parameter, it requires an additional zeroth parameter, making
that final parameter the fourth one rather than the third. The first
parameter indicates the starting point in the string being searched.
Quote:

> If that's the case,
LOL, that word again...
Quote:

> then you can use mixed case.
must be getting the munchies, as I read that as a case of mixed nuts...

/Al

Quote:

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


My System SpecsSystem Spec
Old 08-18-2009   #6 (permalink)
Al Dunbar


 
 

Re: Creating logon scripts - the script will map different sets of drives depending on the security grp the user is in.


"Stefan Kanthak" <postmaster@[127.0.0.1]> wrote in message
news:unTfU70HKHA.4608@xxxxxx
Quote:

> "Al Dunbar" <alandrub@xxxxxx> wrote:
Quote:

>>
>> "RBoyle" <ryan.j.boyle.cpg@xxxxxx> wrote in message
>> news:e619bc0e-0fd5-4c06-a72f-9ae8f05334ae@xxxxxx
Quote:

>>> I'm trying to create a logon scripts that will map my users network
>>> drives based on a certain security group that they are in:
>>>
>>> I'm in the testing stage so far and below is what I have (I'm testing
>>> against our IT security group right now). When I put this in place
>>> its not mapping the drives listed -- could anyone say why and possibly
>>> give me the change I need to do so that those three drives will map.
>>>
>>> Here is my vbscript -- thanks for the help in advance:
>>>
>>> Ryan
>>>
>>> ----------------
>>>
>>> Const IT_GROUP = "cn=IT$ DEPARTMENT (R & W)"
>>>
>>> Set wshNetwork = CreateObject("WScript.Network")
>>> Set ADSysInfo = CreateObject("ADSystemInfo")
>>> Set CurrentUser = GetObject("LDAP://" & ADSysInfo.UserName)
>>>
>>>
>>> strGroups = LCase(Join(CurrentUser.MemberOf))
>
> Const DELIMITOR = "|"
> strGroups = DELIMITOR & LCase(Join(..., DELIMITOR)) & DELIMITOR
>
Quote:

>> I'd suggest displaying this value to see what it is:
>>
>> wscript.echo strGroups
>>
Quote:

>>> If InStr(strGroups, IT_Group) Then
>>
>> I'd suggest changing the above statement to the one just below to avoid
>> upper/lower case mismatches:
>
> And what about substring mismatches?
>
Quote:

>> If InStr(1, strGroups, IT_Group, 1) Then
>
> If InStr(1, strGroups, DELIMITOR & LCase(IT_Group) & DELIMITOR, 1) Then
Quite right, Stefan. I had thought, however, that what was needed here was
an inkling of some of the things the OP could do to find out why his scripts
are not coming up with the results he expects. Giving a complete answer that
addresses all of the problems in my view tends to leave the OP our of the
process of examining his own understanding of the situation.

/Al


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Attempting to write my logon scripts - I want to do an IF / ElseIfstatement and match to what security group the user is in VB Script
Logon Script Causing Laptops To Hang - Problems in script? VB Script
Need help with a logon script for the domain user VB Script
creating Environment variable during logon script VB Script
Creating Powershell Scripts PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46