Cycling through usernames in RT::Users

Does anyone have any code snippet to cycle through all users in a certain
group ?

I’m working on another version of a nag script that will run through each
user’s tickets and toss out reminders. Want to get user’s email address and
name dynamically.

Thanks.

matthew zeier - “In mathematics you don’t understand things. You just
get used to them.” - Johann von Neumann

matthew zeier wrote:

Does anyone have any code snippet to cycle through all users in a certain
group ?

Users->MemberOfGroup() looks like it should do what you want.

matthew zeier wrote:

Does anyone have any code snippet to cycle through all users in a
certain
group ?

Users->MemberOfGroup() looks like it should do what you want.

I was hoping to find something more complete than that. What I have right
now, which isn’t working (I don’t get anything on dumpValue()):

use lib “/opt/rt2/lib”;
use lib “/opt/rt2/etc”;

use RT::Interface::CLI qw(CleanEnv LoadConfig DBConnect
GetCurrentUser GetMessageContent);

CleanEnv();
LoadConfig();
DBConnect();

use RT::Date;
use RT::Queue;
use RT::Tickets;
use RT::Users;

my $users_obj = new RT::Users($RT::SystemUser);
$users_obj->MemberOfGroup(‘6’);

while (my $user = $users_obj->Next) {
dumpValue($user);
}

$RT::Handle->Disconnect();

I don’t appear to enter the while() loop.

  • mz

matthew zeier writes:

I was hoping to find something more complete than that. What I have
right
now, which isn’t working (I don’t get anything on dumpValue()):

Try something like:

use RT::Group;

my $group = new RT::Group($RT::SystemUser);
$group->Load(‘groupname’);
$mo = $group->MembersObj;

while ($groupmember_obj = $mo->Next) {
$user_obj = $groupmember_obj->UserObj;
print $user_obj->Name,“\n”;
}

You need to start with the group, then iterate through the membership,
converting those to users.
-Matt

Very cool, thanks!----- Original Message -----
From: “Matthew D. Stock” stock@cse.Buffalo.EDU
To: “matthew zeier” mrz@intelenet.net
Cc: “Phil Homewood” pdh@snapgear.com; rt-users@lists.fsck.com
Sent: Sunday, February 17, 2002 3:56 PM
Subject: Re: [rt-users] cycling through usernames in RT::Users

matthew zeier writes:

I was hoping to find something more complete than that. What I have
right
now, which isn’t working (I don’t get anything on dumpValue()):

Try something like:

use RT::Group;

my $group = new RT::Group($RT::SystemUser);
$group->Load(‘groupname’);
$mo = $group->MembersObj;

while ($groupmember_obj = $mo->Next) {
$user_obj = $groupmember_obj->UserObj;
print $user_obj->Name,“\n”;
}

You need to start with the group, then iterate through the membership,
converting those to users.
-Matt


rt-users mailing list
rt-users@lists.fsck.com
http://lists.fsck.com/mailman/listinfo/rt-users

Quoting matthew zeier mrz@intelenet.net [17 Feb-02 17:46]:

matthew zeier wrote:

Does anyone have any code snippet to cycle through all
users in a certain group ?

Users->MemberOfGroup() looks like it should do what you want.

I was hoping to find something more complete than that. What I
have right now, which isn’t working (I don’t get anything on
dumpValue()):

use lib “/opt/rt2/lib”;
use lib “/opt/rt2/etc”;

use RT::Interface::CLI qw(CleanEnv LoadConfig DBConnect
GetCurrentUser GetMessageContent);

CleanEnv();
LoadConfig();
DBConnect();

use RT::Date;
use RT::Queue;
use RT::Tickets;
use RT::Users;

my $users_obj = new RT::Users($RT::SystemUser);
$users_obj->MemberOfGroup(‘6’);

while (my $user = $users_obj->Next) {
dumpValue($user);
}

$RT::Handle->Disconnect();

I don’t appear to enter the while() loop.

I think if you ran this under strict you’d find that there is no
dumpValue() defined.

(darren)

If Jesus Christ were to come today, people would not even crucify
him. They would ask him to dinner, and hear what he had to say,
and make fun of it.
– Thomas Carlyle