Page 1 of 1 1
Topic Options
#177649 - 2007-07-09 01:08 PM Connect other share if member of more than 1 group
BunzyBuddy Offline
Fresh Scripter

Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
Hi all,

I'm willing to connect a network drive to a server share if the user is member of a certain domain group. Of course this is easy using IF INGROUP.... etc.
But, how can I verify if an user is member of more than 1 of predefined groups and, if so, connect him to another location or share ?

Please help ???

Job van Dalen

Top
#177650 - 2007-07-09 01:19 PM Re: Connect other share if member of more than 1 group [Re: BunzyBuddy]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Hi, it states how to in the command reference:
 Code:
Example

IF INGROUP("Domain Users")

    DISPLAY "z:\users.txt"

ENDIF

 

IF INGROUP("Developers", "Testers") = 1

    ? "Member of Developers OR Testers group"

ENDIF

 

IF INGROUP("Developers", "Testers", 1) = 1

    ? "Member of Developers AND Testers group"

ENDIF

 

$Array = "Developers", "Testers"

IF INGROUP($Array, 1) = 1

    ? "Member of Developers AND Testers group"

ENDIF

 

IF INGROUP("\\" + @WKSTA + "\Developers") = 1

    ? "Member of Developers on local system"

ENDIF



 Code:
INGROUP ("group name" [<,> "group name 2"], Mode)

 

Parameter

Group name1, group name 2, group name …

Identifies the group(s) in which to check the user's membership. 
Multiple group names may be passed as arguments. Alternatively, 
you may specify a single, one-dimensional, array of which the element(s) are the names of one or more groups to test.

Mode

Optional integer parameter indicating whether or not Ingroup checks for 
groupmembership of one or all groups in the list (default = 0). 
Possible values:

 

0
	

Ingroup checks for membership of ONE of the groups in the list (default).

1
	

Ingroup checks for membership of ALL of the groups in the list.

 

Remarks

INGROUP can be used to check for group membership of groups that exist on
the domain or server where the user is logged on, or to check for group
membership of groups on a specific domain or server.
 
When checking for a local group, INGROUP identifies that the user is indirectly a member of the group by virtue of being a member of a global
group which, in turn, is a member of the local group.




Edited by Björn (2007-07-09 01:30 PM)

Top
#177651 - 2007-07-09 01:39 PM Re: Connect other share if member of more than 1 group [Re: Björn]
BunzyBuddy Offline
Fresh Scripter

Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
Thanx for all replies. Your examples are (as far as I understand) OR member of 1 of selected groups OR member of ALL selected groups. What I want to do is checking if user is member of MORE THAN ONE of the selected groups (2, 3 or 4)

Is that possible ?

Top
#177652 - 2007-07-09 01:49 PM Re: Connect other share if member of more than 1 group [Re: BunzyBuddy]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
and scrolling down some in the examples would have provided you with the information you asked and where given.
 Code:
$Array = "Developers", "Testers"

IF INGROUP($Array, 1) = 1

    ? "Member of Developers AND Testers group"

ENDIF

edit: and after re-reading your reply,
I'm guessing that this might be fun as well:
 Code:
$array = "group1","group2","group3"
For each $group in $array
if ingrop($group) = 1
? 'member of group ' + $group
endif
Next

What is it really that you wanna accomplish?


Edited by Björn (2007-07-09 01:53 PM)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#177653 - 2007-07-09 02:03 PM Re: Connect other share if member of more than 1 group [Re: Björn]
BunzyBuddy Offline
Fresh Scripter

Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
this is my situation:

ROOT
|
--------------------------------
| | | |
Dir1 Dir2 Dir3 Dir4

If user is member of Group_Dir1, his drive would be connected to \\Server\Dir1
If user is member of Group_Dir2, his drive would be connected to \\Server\Dir2
And so on....

But, if user is member of more than one group, lets say he's member of Group_Dir1 and Group_Dir3, his drive has to be connected to the root: \\Server\Root

Top
#177654 - 2007-07-09 02:28 PM Re: Connect other share if member of more than 1 group [Re: BunzyBuddy]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
As Bjorn pointed out in the manual reference, InGroup can verify membership in ANY group, or ALL groups. Simply perform the tests for ALL groups first, since it appears that you want to map one share if a user is a member of 2 groups and a different one if they are a member of 1 group. For example:

 Code:
; map the T: drive
If InGroup('group1','group2',1)
  ; is member of both groups
  Use T: \\server\share1
Else
  If InGroup('group1','group2')
    ; is member of at least 1 group
    Use T: \\server\share2
  EndIf
EndIf


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

Top
#177655 - 2007-07-09 02:37 PM Re: Connect other share if member of more than 1 group [Re: BunzyBuddy]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
I have something you might could use at home - using an ini, but given the critera right now, and if you know that this will only occur once or twice you could try this (just something simple):
Note- This is not tested in anyway more then with eyesight, and I am not wearing my glasses ;\)
 Code:
If INGROUP("Group_Dir1","Group_Dir3",1) 
 use X: "\\server\root"
Else
 Select 
  case INGROUP("Group_Dir1") 
   use x: "\\server\dir1"
  case INGROUP("Group_Dir2") 
   use x: "\\server\dir2"
  case 1
   ;something default..
 EndSelect
EndIf


Looks like Glenn beat me to it ;\)


Edited by Björn (2007-07-09 02:53 PM)
Edit Reason: added warning-note

Top
#177656 - 2007-07-09 02:41 PM Re: Connect other share if member of more than 1 group [Re: Glenn Barnas]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
Thinking about this and your later post, you probably want to use alternate logic.. I use something like this in my "Universal Login Script", which you can download from my site, although the logic would have to be modified slightly for your situation.

 Code:
$OK = 0
; User should be a member of at least one group in the following list
; Define array of group names and share subfolders
$Groups = 'group1','group2','group3'
$Shares = 'dir1', 'dir2', 'dir3'
For Each Group in $Groups
  $OK = $OK + InGroup($Group)
Next

; map a drive if $OK is true
If $OK
  ; but map to the root if $OK is >1 (member of multiple groups
  If $OK > 1
    Use T: '\\server\root'
  Else
    For $I = 0 to UBound($Groups)
      If Ingroup($Groups[$I])
        Use T: '\\server\root\' + $Shares[$I]
      EndIf
    Next
  EndIf
EndIf



This maps T: to the root of the share if the user is a member of 2 or more groups in the list, and to the corresponding subfolder (deep map) if they are a member of only one group.

Glenn




Edited by Glenn Barnas (2007-07-09 03:57 PM)
Edit Reason: typo
_________________________
Actually I am a Rocket Scientist! \:D

Top
#177659 - 2007-07-09 02:56 PM Re: Connect other share if member of more than 1 group [Re: Glenn Barnas]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Sorry Glenn, but I don't really follow the red line in that code, I see what it could do, but it looks, wrong *_*
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#177661 - 2007-07-09 02:57 PM Re: Connect other share if member of more than 1 group [Re: Glenn Barnas]
BunzyBuddy Offline
Fresh Scripter

Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
Thanx Bjorn, thanx Glenn, this is exacly what I needed.
Top
#177662 - 2007-07-09 02:59 PM Re: Connect other share if member of more than 1 group [Re: BunzyBuddy]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
No problem mr Bunzy :). My bad I didn't see what you were aiming first \:\) still a bit rusty.
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#177664 - 2007-07-09 03:08 PM Re: Connect other share if member of more than 1 group [Re: Björn]
BunzyBuddy Offline
Fresh Scripter

Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
No problem Bjorn. Thanx for your help.
Do you realy think there's an error in Glenn's code ?

Top
#177665 - 2007-07-09 03:59 PM Re: Connect other share if member of more than 1 group [Re: BunzyBuddy]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
There were two.. one logic error where I had an EndIf in the wrong place. Must have been suffering from CDD (Caffiene Deficit Disorder) when I wrote it. The second error is Bjorn's, actually - there is NO red line! ;\)

It should work as expected now.

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

Top
#177666 - 2007-07-09 04:02 PM Re: Connect other share if member of more than 1 group [Re: Glenn Barnas]
BunzyBuddy Offline
Fresh Scripter

Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
Haha, thanx Glenn !
Top
#177667 - 2007-07-09 04:10 PM Re: Connect other share if member of more than 1 group [Re: BunzyBuddy]
BunzyBuddy Offline
Fresh Scripter

Registered: 2006-02-22
Posts: 40
Loc: Amsterdam, Holland
Whell, after having corrected some typing-errors, your script does exactly wat I was looking for !
I'm very happy !!
Thanx again !

Top
#177678 - 2007-07-10 08:42 AM Re: Connect other share if member of more than 1 group [Re: Glenn Barnas]
Björn Offline
Korg Regular
*****

Registered: 2005-12-07
Posts: 953
Loc: Stockholm, Sweden.
Glenn, that was it? And I didn't see it.. Gah, I seem to be in dire need of using my glasses all the time ;\)
_________________________
as long as it works - why fix it?
If it doesn't work - kix-it!

Top
#177683 - 2007-07-10 12:29 PM Re: Connect other share if member of more than 1 group [Re: Björn]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
yup - moved the first endif to the end of the code block. It was too early and I was without coffee when I first wrote it. Where I originally had the EndIf closed the first If, and it mapped only if you were a member of multiple groups. I moved the endif and cleaned up the indent, and spend a few more minutes trying to figure out what the RED line was, even thinking about possible typos.. Did you intend to highlight something??

Anyway.. my login script code puts that kind of logic into a UDF that is called for each mapped resource. Returns a boolean indicating that the resource is permitted or not. Handles group, multi-group, and OU memberships (and non-memberships, as well as other mechanisms.

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

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.24 seconds in which 0.138 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