Your post got me to wondering where I had screwed up, and it turns out I
made two incorrect assumptions. First, I thought that VBScript was
consistent with other environments where False=0 and True=1. Not so, as
apparently they decided that True=-1. Second, I assumed that in the If
statement, if your check evaluated to True (or -1, as I see now) then
the code following "Then" would execute, and if the check evaluated to
False (or 0) then the code following "Then" would not execute. Turns out
that is the case from a logical standpoint, but in the implementation if
your check evaluates to anything other than 0, then the code following
"Then" will execute. Kind of subtle, but it could produce unexpected
results, at least for me :-)

Hunter 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Harding, Devon
Sent: Monday, November 14, 2005 7:03 PM
To: [email protected]; [email protected]
Subject: RE: [ActiveDir] strGrooup?

I found the problem.  It seems that my constants were not lower case,
thats why it was not mapping.  I also added 'On Error GoTo 0' after the
removal of the drives to show errors.  The drives mapped with the
original If,Then statements (without the >0).
 
Thanks All...

________________________________

From: [EMAIL PROTECTED] on behalf of Coleman, Hunter
Sent: Mon 11/14/2005 6:36 PM
To: [email protected]
Subject: RE: [ActiveDir] strGrooup?


OK, looking at this a bit closer than my first reply, if the user is in
Windows_Group and/or any of the other groups, what are the odds that
that group will happen to be first in the strGroup string? InStr will
return the position of the first occurrance, so unless it happens to be
the first group in strGroup you're going to get something greater than
1. Your If statements are looking for something that evaluates to 0 or 1
(False or True). So you need to change your evaluation to something like
If (InStr(strGroup, Windows_group) > 0) Then ....
End If
 
But that's not why you were getting the drives mapped. You have Option
Explicit set at the start, then you have On Error Resume Next. When you
try to use strGrooup (that isn't defined), the script errors but then
continues on to the next line. Get rid of the On Error Resume Next and
change your If statements, and you should be set. If you want to do some
error checking, you can put the On Error Resume Next back in but check
to see what Err.Number is after your If statements. As long as it is
zero, you can continue with the drive mapping.
 
Hunter

________________________________

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Harding, Devon
Sent: Monday, November 14, 2005 4:05 PM
To: [email protected]
Subject: [ActiveDir] strGrooup?



I cannot figure this one out.  Why doesn't the following script work
when I use 'strGroup', instead, it works (maps drives) when I use
strGrooup.  strGrooup isn't even defined.

 

Option Explicit

Dim objNetwork, objUser, CurrentUser, objFSO

Dim strGroup

 

Const Windows_Group = "BSG - IS Windows Systems"

Const Pricing_Group = "gs-ssd-pricing"

Const IPCC_Group = "IPCCGroup"

Const IXOS_Group = "IXOS_ScanPost_Common"

 

Set objNetwork = CreateObject("WScript.Network")

' Forces script to skip errors (rem below line to see errors)

on error resume next

 

Dim WshNetwork

Set WshNetwork = WScript.CreateObject("WScript.Network")

' Set all drives to be removed here.

WshNetwork.RemoveNetworkDrive "e:"

WshNetwork.RemoveNetworkDrive "f:"

 

Set objUser = CreateObject("ADSystemInfo")

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

strGroup = LCase(Join(CurrentUser.MemberOf))

 

if instr(strGrooup, Windows_Group) then

 objNetwork.MapNetworkDrive "s:", "\\gsfps2\siteshare"

 objNetwork.MapNetworkDrive "u:", "\\gsfps2\users"

end if

 

if instr(strGroup, IXOS_Group) then

 objNetwork.MapNetworkDrive "e:", "\\gsimage2\IXOS_ScanPost_Common\Late
Archive"

 objNetwork.MapNetworkDrive "f:",
"\\gsimage2\IXOS_ScanPost_Common\Common Post"

 objNetwork.MapNetworkDrive "i:",
"\\gsimage2\IXOS_ScanPost_Common\Normal"

 objNetwork.MapNetworkDrive "j:",
"\\gsimage2\IXOS_ScanPost_Common\Demand"

 objNetwork.MapNetworkDrive "k:",
"\\gsimage2\IXOS_ScanPost_Common\Emergency"

end if

 

Devon Harding

Windows Systems Engineer

Southern Wine & Spirits - BSG

954-602-2469

 

________________________________

__________________________________
This message and any attachments are solely for the intended recipient
and may contain confidential or privileged information. If you are not
the intended recipient, any disclosure, copying, use or distribution of
the information included in the message and any attachments is
prohibited. If you have received this communication in error, please
notify us by reply e-mail and immediately and permanently delete this
message and any attachments. Thank You. 

List info   : http://www.activedir.org/List.aspx
List FAQ    : http://www.activedir.org/ListFAQ.aspx
List archive:
http://www.mail-archive.com/activedir%40mail.activedir.org/
List info   : http://www.activedir.org/List.aspx
List FAQ    : http://www.activedir.org/ListFAQ.aspx
List archive: http://www.mail-archive.com/activedir%40mail.activedir.org/

Reply via email to