[rt-users] importing users question...
Roy El-Hames
rfh at pipex.net
Wed Nov 15 10:59:32 EST 2006
Matt;
If you have your users and group already created , you can use the below
scripts to add group membership ..
I have a separate script that create users,and another to create groups
if you wish, something to bare in mind when creating users is most of
the time the users exist in the system because the 've emailed the
system and RT auto created them
Roy
#!/usr/bin/perl
use lib "/opt/rt3/lib";
use strict;
use RT;
use RT::Interface::CLI qw(CleanEnv);
CleanEnv();
RT::LoadConfig();
RT::Init();
my $group = "Your group";
my @users =('user 1','user 2','user 3') ;
##load Group object
my $gobject = new RT::Group (RT::SystemUser);
$gobject->LoadUserDefinedGroup($group);
foreach my $u (@users) {
##load user object
my $user=RT::User->new(RT::SystemUser);
my ($s, $msg) = $user->Load($u);
print "we loaded user $u his id is $user->Id \n";
if ($s) {
my ($gmd, $msg) = $gobject->AddMember($user->PrincipalId);
if ($gmd == 0 ) {
print "Could not add $u to this group error is $msg \n";
}
}
}
exit;
Mat W wrote:
> I'm using RT3.4.0
>
> I've read through some of the posts and the wiki. Everyone seems to
> think it's possible including myself and honestly, doesn't seem that
> hard to do... however I've yet to see someone say, "yes, i imported
> 100 users with <blah> technique/script, etc". The script on the wiki
> shows how to create a user, but i don't see how it updates the Group
> tables.
>
> I was looking around in the DB. I see it creates the entries in the
> Users, Groups, and GroupMembers. I believe I could create one
> "example" user and see what changes in the DB and script it myself to
> essentially "clone" the user 100 more times. I'm just hoping someone
> may have already created a "clone" script or can point out things like
> "don't forget about updating <blah>".
>
> I'm no super-DBA or programmer, but i can muddle my way through it.
> Just need a shove in the right direction. Perhaps what function is
> called when RT auto-creates the users who emailed tickets in?
>
> thanks in advance.
>
> -MatW
>
> _________________________________________________________________
> Find a local pizza place, music store, museum and more…then map the
> best route! http://local.live.com?FORM=MGA001
>
> _______________________________________________
> 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
>
More information about the rt-users
mailing list