Importing users

Dear all,

I have a bunch of users (in a csv file) and would like to import them into RT. What is the best way to do it?

Best regards,
David

David Obando
Webmaster/Systemadministrator
Egmont Ehapa Verlag GmbH
Wallstraße 59
10179 Berlin
Germany
Phone: +49 30 240080
Direct: +49 30 24008361
Mobil: +49 172 1548386
Fax: +49 30 24008369
d.obando@ehapa.de
www.ehapa.de http://www.ehapa.de/

Geschäftsführer: Frank Knau, Karl Skovbæch Pedersen | Handelsregister: HRB 81977 AG Berlin-Charlottenburg | Sitz der Gesellschaft: Berlin

EGMONT

Dear all,

I have a bunch of users (in a csv file) and would like to import
them into RT. What is the best way to do it?

The Wiki is your friend. :slight_smile:

I did it with code something like this (untested):

#!/usr/bin/perl
use strict;
use warnings;

use lib '/path/to/rt/lib';
use RT::Interface::CLI;

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

my $rt_user = RT::User->new($RT::SystemUser);
while (<>) {
my ($id, $name, $passwd, $email) = split /,/;

my ($rc, $msg) =
    $rt_user->Create(Name         => $id,
		     RealName     => $name,
		     Password     => $passwd,
		     EmailAddress => $email,
		     Privileged   => 1,
		    );
unless ($rc) {
    print "add user $id: $msg\n";
}
}

The split() is probably inadequate – you might want to use
Text::ParseWords to be more robust.

After a user is added, you might want to include that user in a user
defined group (untested):

my $rt_group = RT::Group->new($RT::SystemUser);
$rt_group->LoadUserDefinedGroup('my_group_name');
my ($rc, $msg) = $rt_group->AddMember($rt_user->PrincipalId());

unless ($rc) {
print "can't add $id to my_group_name: $msg\n";
}

Garry T. Williams — 678-370-2438