[rt-users] importing users question...and adding them to a group

Stephen Turner sturner at MIT.EDU
Mon Nov 20 16:51:10 EST 2006


> -----Original Message-----
> From: rt-users-bounces at lists.bestpractical.com 
> [mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Mat W
> Sent: Monday, November 20, 2006 3:28 PM
> To: rt-users at lists.bestpractical.com
> Subject: [rt-users] importing users question...and adding 
> them to a group
> 
> i have the little perl scirpt that adds users via the backend 
> just fine.  
> now how do i script it so the users get added to a group?  
> I'm thinking it's 
> the GroupMember.pm file using the "Create" method.
> 

No, you first need to load the group and then add add the user to the group:

my $groupname = 'a-group-name';
my $username = 'a-user-name';

my $group = RT::Group->new(RT::SystemUser);
$group->LoadUserDefinedGroup($groupname);

my $user = RT::User->new(RT::SystemUser);
$user->Load($username);

$group->AddMember($user->PrincipalObj->id);


To figure out these kinds of things I've always found it helpful to go to
the relevant place in the web interface (in this place the group "Members"
screen) to see how things are done. 

Steve
  




More information about the rt-users mailing list