Creating a user using a simple perl script

Can someone tell me how to first see if a user name exists and if not how
to add a user? Once I get it adding a user I can figure out how to do all
the other user fields. I’m pretty good with perl, but the error that is
produced with the short/quick/dirty script I have is over my head.

By the way: I’ve added the lib dir for RT perl modules to the search path
for perl so its including RT::User (RT/ without a problem. However…

Here is my code:

use RT::User;
$NewUser = RT::User->new($RT::SystemUser);

         ( $Val, $Message ) = $NewUser->Create(
                               Name => "",
                               EmailAddress => 

RealName => “Person J Smith”,
Password => “SuperMan”,
Privileged => 0,
Comments => ‘Autocreated by external

This produces this error:


at /usr/local/lib/perl5/5.8.0/RT/ line 54
RT::Base::CurrentUser(‘RT::User=HASH(0x813be40)’,‘undef’) called
at /usr/local/lib/perl5/5.8.0/RT/ line 67
RT::Record::_Init(‘RT::User=HASH(0x813be40)’,‘undef’) called at
/usr/local/lib/perl5/5.8.0/RT/ line 57
RT::User::_Init(‘RT::User=HASH(0x813be40)’,‘undef’) called at
/usr/local/lib/perl5/site_perl/5.8.0/DBIx/SearchBuilder/ line 344
DBIx::SearchBuilder::Record::new(‘RT::User’,‘undef’) called at
line 21
called at ./ line 4
Can’t call method “err” on an undefined value at
/usr/local/lib/perl5/5.8.0/RT/ line 54.

I’ve tried some more, but still can’t figure it out. If anyone knows how
to do this, please let me know.

At 11:48 PM 4/10/2003 -0700, Landon Stewart wrote: