On 2/15/2007 11:04 AM, Torsten Brumm | Kuehne + Nagel wrote:

Again just another question for the CLI Part. Has anyone a idea how to add a
set of users per scrip to a group?

Lets say, i have a list of 500 User that are needed to be member of a single
group?

I did something similar via a full perl script (as opposed to using the CLI). Here are some excerpts (untested in this form):

#!/usr/bin/perl -w

use strict;
use lib "/opt/rt3/lib";

use RT;
use RT::Interface::CLI qw(CleanEnv GetCurrentUser);
use RT::Group;
use RT::User;

CleanEnv();
RT::LoadConfig();
RT::Init();

my($groupname) = 'FooBar';
my($group) = RT::Group->new($RT::SystemUser);
$group->LoadUserDefinedGroup($groupname);
die qq([ERROR] Cannot load group "$groupname"\n) unless $group->id;

my(@users) = GetListOfUsernames();
foreach my $username (@users) {
   my($user) = RT::User->new($RT::SystemUser);
   $user->Load($username);
die qq([ERROR] Could not load user "$username" -- see log for details\n) unless $user->id;

   my($status, $msg) = $Groups->{$groupname}->AddMember($user->id);
die qq([ERROR] Cannot add user "$id" to group "$groupname" - $msg\n) unless $status;
}

--
Regards,


joe
Joe Casadonte
[EMAIL PROTECTED]

==========                                                  ==========
== The statements and opinions expressed here are my own and do not ==
== necessarily represent those of Oracle Corporation.               ==
==========                                                  ==========
_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. Buy a copy at http://rtbook.bestpractical.com

Reply via email to