Members of group

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.

Also, not sure if Recusively => 0 is coded properly.

Any suggestions will be appreciated and thanks.

Roman

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 );