Page 1 of 1 1
Topic Options
#127792 - 2004-10-13 12:40 AM Calling kix files with arrays
Incognito Offline
Getting the hang of it

Registered: 2001-07-09
Posts: 66
In the beginning, I was mapping department resources using the following format:

If InGroup ("ACCOUNTING")
Call "accounting.Kix"
EndIf


If InGroup ("Custsvc")
Call "custsvc.kix"
EndIf

By keeping the NT group names consistant with the associated kix resources we were able to complete the same task like this:

$members = "accounting","custsvs"
For Each $Element In $MEMBERS
? $Element
If InGroup ($Element)
? "-->" $Element
Call $Element+".KIX"
EndIf
Next

Is there an easier way to do this?

Top
#127793 - 2004-10-13 01:25 AM Re: Calling kix files with arrays
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Use an .INI file instead for the mappings.
_________________________
There are two types of vessels, submarines and targets.

Top
#127794 - 2004-10-13 10:07 AM Re: Calling kix files with arrays
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here is something similar to that which I use:
Code:
$sScriptPath=@SCRIPTDIR

$iIndex=0
$sGroup=EnumGroup($iIndex)
While Len($sGroup)
; Strip domain
If InStr($sGroup,"\") $sGroup=SubStr($sGroup,InStr($sGroup,"\")+1) EndIf
If Exist($sScriptPath+"\"+$sGroup+".kix")
"Calling login script for group "+$sGroup+@CRLF
Call $sScriptPath+"\"+$sGroup+".kix"
Else
"No login script for group "+$sGroup+@CRLF
EndIf
$iIndex=$iIndex+1
$sGroup=EnumGroup($iIndex)
Loop



You might also want to replace space characters in the group names with something a bit more handy, but it is not necessary.

Note, I strip off the domain name - you might want to leave it in place and store domain group scripts in a subdirectory.

Top
#127795 - 2004-10-13 02:28 PM Re: Calling kix files with arrays
ChristopheM Offline
Hey THIS is FUN
*****

Registered: 2002-05-13
Posts: 311
Loc: STRASBOURG, France
you could imagine also to list groups and script name in a text file.

example :
group1;my script for group1.kix
group2;my script for group2.kix
group3;my script for group3.kix

then you read this file and test for each line if user is in group
(comment a line with a ";" )
Code:
$handle=freefilehandle()
if open($handle, "ListGroup.txt",2)=0
$line=Readline($handle)
while not @error
$line=trim($line)
if left($line,1) <> ";"
$array=split($line, ";" )
$group = $array[0]
$scriptname = $array[1]
if InGroup($group)
if exist($scriptname)
call $scriptname
endif
endif
endif
$line=Readline($handle)
loop
$=close($handle)
endif



This code is not very secured and I haven't tested it but it could be a good start.

For performances, it is important to know the average of groups people are in and the average of groups associated with a script.
_________________________
Christophe

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 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.065 seconds in which 0.038 seconds were spent on a total of 12 queries. Zlib compression enabled.

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