Page 1 of 1 1
Topic Options
#192188 - 2009-02-12 04:22 PM Odd issue with nested IF statements.
danf Offline
Fresh Scripter

Registered: 2009-02-09
Posts: 9
Loc: West Virginia, USA
Below is a section of code that I am trying to implement. The first section under the the first IF sets a list of default drive shares. This is followed by a series of IF statements that will assign drives based on if a person is in that group. I changed the script to remove internal naming but that was it.

 Code:
;/*For MyWork Office */
IF InGroup ("Wor MyWorkOffice Staff")
      ;/For General Users
      SETTIME "\\server-fs"
      USE P: "\\server-fs\@userid$"
      USE Q: "\\server-fs\common"
      USE X: "\\192.168.X.XX\database"
      USE Y: "\\192.168.X.XX\export"
      USE H: "\\192.168.X.X\fax-scan"

      ;/Mappings Based on Group Memberships
      IF InGroup ("Wor-MyWorkOffice-Loans")
	USE I: "\\server-fs\common\01-Loans"
      ENDIf
      IF InGroup ("Wor-MyWorkOffice-Tellers")
	USE J: "\\server-fs\common\02-Tellers"
      ENDIf
      IF InGroup ("Wor-MyWorkOffice-NewAcct")
	USE K: "\\server-fs\common\03-New Accounts"
      ENDIf
      IF InGroup ("Wor-MyWorkOffice-Collect")
	USE L: "\\server-fs\common\04-Collections"
      ENDIf
      IF InGroup ("Wor-MyWorkOffice-Book")
	USE M: "\\server-fs\common\05-Bookkeeping"
      ENDIf
      IF InGroup ("Wor-MyWorkOffice-ExecMgmt")
	USE N: "\\server-fs\common\06-Exec Mgmt"
      ENDIf
      IF InGroup ("Wor-MyWorkOffice-Operations")
	USE O: "\\server-fs\common\07-Operations"
      ENDIf
ENDIf

Whenever I run this using the script editor it lists each of the if statement checks but does not perform the use below it or even the endif. Can any of you guys see what I've missed?

Thanks.

-Dan


Edited by Allen (2009-02-12 04:25 PM)
Edit Reason: added code tags

Top
#192190 - 2009-02-12 04:35 PM Re: Odd issue with nested IF statements. [Re: danf]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
it lists?
the script editor?

I don't see mismatch in quotes or any faulplay.
I suggest you run the script again without any editors via console and add some basic debug code, as example:

 Code:
     ;/Mappings Based on Group Memberships
      IF InGroup ("Wor-MyWorkOffice-Loans")
? "in group loans"
	USE I: "\\server-fs\common\01-Loans"
? "use returned error: " @error
else
? "not in group loans"
      ENDIf
sleep 4
 


etc, to see what it really does.
_________________________
!

download KiXnet

Top
#192193 - 2009-02-12 04:53 PM Re: Odd issue with nested IF statements. [Re: danf]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Have you changed KiXtart versions?
Top
#192194 - 2009-02-12 05:00 PM Re: Odd issue with nested IF statements. [Re: Richard H.]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here is a version with some error checking:
 Code:
;/*For MyWork Office */
IF InGroup ("Wor MyWorkOffice Staff")
      ;/For General Users
      SETTIME "\\server-fs"
      USE P: "\\server-fs\@userid$"
      USE Q: "\\server-fs\common"
      USE X: "\\192.168.X.XX\database"
      USE Y: "\\192.168.X.XX\export"
      USE H: "\\192.168.X.X\fax-scan"

      ;/Mappings Based on Group Memberships
      MyUse("Wor-MyWorkOffice-Loans","I:","\\server-fs\common\01-Loans")
      MyUse("Wor-MyWorkOffice-Tellers","J:","\\server-fs\common\02-Tellers")
      MyUse("Wor-MyWorkOffice-NewAcct","K:","\\server-fs\common\03-New Accounts")
      MyUse("Wor-MyWorkOffice-Collect","L:","\\server-fs\common\04-Collections")
      MyUse("Wor-MyWorkOffice-Book","M:","\\server-fs\common\05-Bookkeeping")
      MyUse("Wor-MyWorkOffice-ExecMgmt","N:","\\server-fs\common\06-Exec Mgmt")
      MyUse("Wor-MyWorkOffice-Operations","O:","\\server-fs\common\07-Operations")
ENDIf

Function MyUse($sGroup,$sLetter,$sPath)
	If InGroup($sGroup)
		"I am in group '"+$sGroup+"' so will try to map '"+$sPath+" as drive "+$sDrive+@CRLF
		Use $sLetter $sPath
		If @ERROR "ERROR mapping drive: ["+@ERROR+"] "+@SERROR+@CRLF
	Else
		"I am not in group '"+$sGroup+@CRLF
	EndIf
EndFunction

Top
#192198 - 2009-02-12 05:28 PM Re: Odd issue with nested IF statements. [Re: Richard H.]
danf Offline
Fresh Scripter

Registered: 2009-02-09
Posts: 9
Loc: West Virginia, USA
I'm using the new and most current version of Kix.
Top
#192199 - 2009-02-12 06:13 PM Re: Odd issue with nested IF statements. [Re: danf]
danf Offline
Fresh Scripter

Registered: 2009-02-09
Posts: 9
Loc: West Virginia, USA
I think I may have figured it out. I had a nested group within the "Wor-MyWorkOffice-Loans" group that contained the test user account. Once I created a separate if statement for the group that had been nested, things worked great.

Now my next problem seems to be dealing with this setdefaultprinter section. I have it setup as follows:

IF InGroup ("Branch-UpperPrint")
SetDefaultPrinter("\\server-fs\branchupstairs")
ENDIf
IF InGroup ("Branch-LowerPrint")
SetDefaultPrinter("\\server-fs\branchdownstrs")
etc...

It always sets the default printer to be the upperprint one no matter what.

Any thoughts on this? Thanks a ton for the help.

-Dan

Top
#192201 - 2009-02-12 06:59 PM Re: Odd issue with nested IF statements. [Re: danf]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
If a user is a member of multiple groups, you need to order your logic from most specific to least specific. If you use If statements, you also need to add logic to prevent setting default printers on less-specific groups, so Select/Case would be a better logic choice.

Again, add debugging messages to verify the username and which logic is being processed. My Dbg() udf make this easy by simply declaring a global $DEBUG value and setting it to 1 to display messages and 0 to not. Its actually part of a small UDF library called MSG() that handles various type of screen/log output.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#192205 - 2009-02-12 08:00 PM Re: Odd issue with nested IF statements. [Re: Glenn Barnas]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
also, are you using addprinterconnection() too?
as simply setting the default printer does not cause the printers to be added and if you want to control the printers, you should also control what printers are connected.

if you are using addprinterconnection() too, then I might know what's the deal here...
_________________________
!

download KiXnet

Top
#192246 - 2009-02-13 03:57 PM Re: Odd issue with nested IF statements. [Re: Lonkero]
danf Offline
Fresh Scripter

Registered: 2009-02-09
Posts: 9
Loc: West Virginia, USA
Yeah Added the printer prior to the set default printer. As it turns out I think I figured it out. Apparently I had figured in my code staring induced stuper that if I have a nested group nested within another that I could call the master group and Kix would still apply the membership of all the members of the nested group. Once I manually added each of the people to the main group it worked without a hitch. Thanks a ton guys. I was sitting here wringing my fist at my script and here it was my AD that was causing the problem.

-Dan

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1270 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.057 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org