[rt-users] CLI Question - Add Users to group per Scrip

Torsten Brumm torsten.brumm at googlemail.com
Fri Feb 16 02:11:59 EST 2007


Hi Joe,

thats exactly what i'm looking for.

Just a small question to this scrip:

my(@users) = GetListOfUsernames();

Do you get with this a list from RT Users Table ?

Thanks

Torsten

2007/2/15, Joe Casadonte <joe.casadonte at oracle.com>:
>
> 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
> joe.casadonte at oracle.com
>
> ==========                                                  ==========
> == 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: sales at bestpractical.com
>
>
> Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
> Buy a copy at http://rtbook.bestpractical.com
>



-- 
MFG

Torsten Brumm

http://www.torsten-brumm.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20070216/9017ae26/attachment.htm>


More information about the rt-users mailing list