TestGroupMembership
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
If you want to test for group membership, you can do it the following way:
my $GroupObj = RT::Group->new($user); $GroupObj->LoadUserDefinedGroup( 'IT Staff' ); my $PrincipalObj = RT::Principal->new($user); $PrincipalObj->Load($user->id); my $prinid = $user->PrincipalId; print $user->Name . "\n"; #Note: These are debugs print $GroupObj->Name . "\n"; #Remove them from production print $PrincipalObj->PrincipalType . "\n"; # if ($GroupObj->HasMemberRecursively($PrincipalObj)) { do_stuff(); #Fill in with work to do }