Page 1 of 2 12>
Topic Options
#18622 - 2002-03-13 10:38 PM Multiple INGROUP()
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I have a problem that deals with mapping drives for user groups... if a user is a member of more than one of a subset of groups I would like to skip a section of code. The only method I can think of is to use and index variable that inc that variable after checking for each group membership... this would be bulky.. is there a better way.

code:
 $index=0


if ingroup("A")
$index=$index+1
endif

if ingroup("B")
$index=$index+1
endif

if ingroup("C")
$index=$index+1
endif

if ingroup("D")
$index=$index+1
endif

if $index > 1
$SKIP = "Y"
else
$skip="N"
endif

This would work but there are many groups... on a side note how does this group checking work? Does it check each time the user logs in for the membership? Does it make requests to the logon server?

Thanks for the help.
_________________________
Austin Henderson

Top
#18623 - 2002-03-13 10:41 PM Re: Multiple INGROUP()
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
For info on how it works see:
http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=002805
http://81.17.37.55/board/ultimatebb.php?ubb=get_topic;f=2;t=002804
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#18624 - 2002-03-13 10:57 PM Re: Multiple INGROUP()
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
So essentially in 4.02 or > the security token is being used.. no excessive queries to the DC correct?
_________________________
Austin Henderson

Top
#18625 - 2002-03-13 10:57 PM Re: Multiple INGROUP()
netixpc Offline
Fresh Scripter

Registered: 2002-02-13
Posts: 19
Loc: Lausanne - Switzerland
KIX 4.0x do not check the group membership at each logon. It is cached in the registry and is updated every 30 days by default. You can force the update at each logon by setting the "-f" parameter when launching kix in your batch file:

%0\..\kix32.exe %0\..\login.kix -f

This is a new behaviour in versions 4.0x. I think everybody should force the group membership update to avoid problems, for example when you create new groups -> IF INGROUP may not work at next logon, but after a few days. Hum hum..
_________________________
SAVE THE WORLD - PROTECT THE PLANET

Top
#18626 - 2002-03-13 11:02 PM Re: Multiple INGROUP()
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I have not had any issues with this as you state. Where is this information being stored in the registry as you say.
_________________________
Austin Henderson

Top
#18627 - 2002-03-13 11:08 PM Re: Multiple INGROUP()
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
code:
 $INDEX=0

if ingroup ("Accounting Security")
$INDEX=$INDEX+1
endif

if ingroup ("Compliance Security")
$INDEX=$INDEX+1
if $index > 1
goto multigrp
endif
endif

if ingroup ("Customer Service Security")
$INDEX=$INDEX+1
if $index > 1
goto multigrp
endif
endif

if ingroup ("IT Security")
$INDEX=$INDEX+1
if $index > 1
goto multigrp
endif
endif


if ingroup ("Maintenance Security")
$INDEX=$INDEX+1
if $index > 1
goto multigrp
endif
endif


if ingroup ("Recruiting Security")
$INDEX=$INDEX+1
if $index > 1
goto multigrp
endif
endif

if ingroup ("Safety Security")
$INDEX=$INDEX+1
if $index > 1
goto multigrp
endif
endif

if ingroup ("Human Resources Security")
$INDEX=$INDEX+1
if $index > 1
goto multigrp
endif
endif

if ingroup ("Risk Management Security")
$INDEX=$INDEX+1
if $index > 1
goto multigrp
endif
endif

Ugly but it works... any thoughts on making it better?
_________________________
Austin Henderson

Top
#18628 - 2002-03-13 11:08 PM Re: Multiple INGROUP()
cellnet Offline
Starting to like KiXtart

Registered: 2002-02-26
Posts: 115
Loc: Sweden
Why not use @PRIMARYGROUP

select
case @PRIMARYGROUP = "a"
use x: "\\server\@userid"

endselect

Not sure this was the problem, but anyway

Regards
erik

Top
#18629 - 2002-03-13 11:09 PM Re: Multiple INGROUP()
netixpc Offline
Fresh Scripter

Registered: 2002-02-13
Posts: 19
Loc: Lausanne - Switzerland
If I remember, it is in:

HKCU\Software\Kixtart\...

The group membership is stored but not updated everytime (my experience). If I create a new group, wait the next day and logon again, it returns a 0 value with the INGROUP function. If I force the update at each logon, I can see (in the registry or by using the enumgroup function) that I'm member of the group. So I forced the update at each logon -> it works and it is not slower.
_________________________
SAVE THE WORLD - PROTECT THE PLANET

Top
#18630 - 2002-03-13 11:10 PM Re: Multiple INGROUP()
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
you could also use a SELECT/CASE for some of these...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#18631 - 2002-03-13 11:25 PM Re: Multiple INGROUP()
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Good sugguestiong on that @PRIMARY but it that is not the case... it is for those users that may be a member of more than one group they will be mapped to a higher level so they can get to the other folders... those users that are members of only one group will be mapped to the folder of their department.

Thanks for the sugguestions...
_________________________
Austin Henderson

Top
#18632 - 2002-03-13 11:27 PM Re: Multiple INGROUP()
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
You say and is not slow.. can you clarify...

I see the key and the groups.. very interesting.. and you are saying these dont update each time at logon? odd isnt that?
_________________________
Austin Henderson

Top
#18633 - 2002-03-14 01:09 AM Re: Multiple INGROUP()
netixpc Offline
Fresh Scripter

Registered: 2002-02-13
Posts: 19
Loc: Lausanne - Switzerland
They implemented the group-membership cache in order to make the execution of the script faster (a lot less query on the windows token, as the query is made every 30 days instead of at each logon). So if I force the update of the cache at each logon with the "-f" parameter, it should mean my script will execute slower.
But for my 1800 user who execute the kix32.exe from the netlogon, the logon script is not slower if I force the update at each logon.
So I prefer force the update at each logon (= solved my problems) than having trouble with the INGROUP (and others) function for new or modified NT groups.
For your drive mapping, it seems a bit complicated like you do. You should use CASE SELECT or INGROUP and GOTO functions. Everybody use it like that. But maybe you have some requirements I don't know...
Just an information, there is a new Kix version 4.10, but it is an Alpha release. Maybe it is better not to use it in a working environment. Don't know why it is not clearly written.
_________________________
SAVE THE WORLD - PROTECT THE PLANET

Top
#18634 - 2002-03-14 04:50 AM Re: Multiple INGROUP()
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I understand the normal use of the way to map drives.. it will not work for me and I will explain so that you can get the picture... I have a drive mapped as S: to all users.. it is a shared drive that has departmental folders in it.. I also have department members that I want to map to say the I: drive and that will be directly to their dept. folder so they will not have to navigate through the S: drive to get there.. just a convenience thing. Well I have some people that will be members of multiple depts and I do not want to map the I drive for those users.. just the S: ... So to keep from creating MORE groups I want to check for membership in multiple groups.. and if so then skip the I: mapping portion... make sense? I know it is cumbersome the way that I have it but it works for me.. by the way what are your link speeds like when you say you do not notice a difference in the logon?

Thanks for the advice.

Later
_________________________
Austin Henderson

Top
#18635 - 2002-03-14 05:45 AM Re: Multiple INGROUP()
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Been down that road before... giving users two drive letters to the same data, with one deeper mapped. Had too many users figured they somehow had two copies of everything so they'd delete one of them. DOH!

Now I have just one drive letter to a DEPT share and they can walk the tree. Most apps let you set their 'start in' folder or come back to where you were last so no big deal.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#18636 - 2002-03-14 08:19 AM Re: Multiple INGROUP()
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
here is an example on how to quickley work with multiple groups.

code:
break on


do
$temp = ENUMGROUP($Index)
$groups = $temp+",$groups"
$Index=$Index+1
until Len($temp) = 0

$groups = split(substr($groups,2,len($groups)),",")
redim preserve $groups[ubound($groups)-1]

? "Number of groups @userid is a member of = " ubound($groups)+1

for each $group in $groups
? $group
next

you can filter this through a single select case, of just check for certain group memberships....

Bryce

Top
#18637 - 2002-03-14 02:25 PM Re: Multiple INGROUP()
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
I am sorry I am still relatively new to kix and I am a little lost in the previous post of code. I very much appreciate your sugguestion and I am wondering if you could comment or maybe give a little explantion to me. Specifically where are you selecting a certing set of groups to check for

Thanks for your willingness to help.
_________________________
Austin Henderson

Top
#18638 - 2002-03-14 06:43 PM Re: Multiple INGROUP()
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
All my code above example does is build an array of groups that the users is a member of. Having this data in an array makes it easy to walk through the information in less amount of code.

I guess I am still a little bit confused on what you are wanting to do.

Are you wanting to do only X action if a user is in Y set of groups?

code:
if ingroup("things") and ingroup("stuff")
;only do something if this user is in both of the things and stuff groups.
endif

or

code:
if ingroup("things") <> 1 and ingroup("stuff") <> 1
;only do something if this user is not in both of the things and stuff groups.
endif

Bryce

Top
#18639 - 2002-03-14 06:50 PM Re: Multiple INGROUP()
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
No this is not what I am trying to do...

I have a drive mapped to all users as S: this drive contains subsets for department and remote locations. I am going to map additionally a subfolder of the S: for users of department X. I know how to accomplish this... the problem comes for those users that are members of several departments security priv. for example those execs that need to be able to get into those folders... they are members of the groups that would cause them to get the drive mapped.. I do not want to do this.. and I do not want to create any additional groups to use as a check.. so I need to see if a users is a member of more than one of these groups (GROUPX, GROUPY, GROUPZ) then skip the mapping of the dept drive.. they will still have S: which is the upper level of these folders anyway.

Thank you for your sugguestion although I feel the code I have will work it is just not as neat.

Thanks again for all your help.
_________________________
Austin Henderson

Top
#18640 - 2002-03-14 06:56 PM Re: Multiple INGROUP()
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
Bryce,

Very nice piece of code. Works great on my system. You're becoming quite an Array junky like Bill I guess.

Top
#18641 - 2002-03-14 10:30 PM Re: Multiple INGROUP()
jameso Offline
Lurker

Registered: 2002-03-08
Posts: 1
Loc: Ireland
This is my first post so forgive any silly mistakes,

ingroup should return > 0 if user is in a group so,
a simple test of mutiple named groups to acheive what you want could be something like :
$G1 = ingroup("G1")
$G2 = ingroup("G2")
$G3 = ingroup("G3")
$Total = $G1 + $G2 + $G3
if $Total > 1 then
; in more than one group
else
if $Total = 1 then
; in only one group
if $G1 > 0 then ; no need to check ingroup again, use stored result from initial test
; map G1 drives
endif
; repeat above as needed
endif
endif

James. [Smile]

Top
Page 1 of 2 12>


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

Who's Online
0 registered and 657 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.099 seconds in which 0.017 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