[rt-users] Members of group

Todd Chapman todd at chaka.net
Fri Mar 17 08:13:40 EST 2006


On Fri, Mar 17, 2006 at 06:35:16AM -0500, Roman Steven wrote:
> Hi,
> 
> Trying to determine if a user is part of a group.  The following works fine
> when the user is in the group but fails when not.
> 
> my $Name = "GroupName";
> my $Groups = new RT::Groups($RT::SystemUser);
> $Groups->LimitToUserDefinedGroups();
> $Groups->Limit(FIELD => "Name", OPERATOR => "=", VALUE => "$Name");
> $ggroups->WithMember(PrincipalId => $session{'CurrentUser'}->id,
> Recusively => 0);
> 
> my $Groupid = $Groups->First->Id;
> 
> The above line is where it fails when user is not part of the group.

my $Group = RT::Group->new( $RT::SystemUser );
$Group->LoadUserDefinedGroup($Name);
my $has_member = $Group->HasMemberRecursively( $session{'CurrentUser'}->PrincipalObj );



More information about the rt-users mailing list