[rt-devel] Creating a user using a simple perl script...

Landon Stewart lstewart at superb.net
Fri Apr 11 02:48:17 EDT 2003


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/User.pm) without a problem.  However...

Here is my code:
#!/usr/bin/perl

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

             ( $Val, $Message ) = $NewUser->Create(
                                   Name => "testdomain.com",
                                   EmailAddress => 
"emailaddress at testdomain.com",
                                   RealName     => "Person J Smith",
                                   Password     => "SuperMan",
                                   Privileged   => 0,
                                   Comments => 'Autocreated by external 
system.'
             );


This produces this error:
# ./useradd.pl
  at /usr/local/lib/perl5/5.8.0/RT/Base.pm line 54
         RT::Base::CurrentUser('RT::User=HASH(0x813be40)','undef') called 
at /usr/local/lib/perl5/5.8.0/RT/Record.pm line 67
         RT::Record::_Init('RT::User=HASH(0x813be40)','undef') called at 
/usr/local/lib/perl5/5.8.0/RT/User.pm line 57
         RT::User::_Init('RT::User=HASH(0x813be40)','undef') called at 
/usr/local/lib/perl5/site_perl/5.8.0/DBIx/SearchBuilder/Record.pm line 344
         DBIx::SearchBuilder::Record::new('RT::User','undef') called at 
/usr/local/lib/perl5/site_perl/5.8.0/DBIx/SearchBuilder/Record/Cachable.pm 
line 21
         DBIx::SearchBuilder::Record::Cachable::new('RT::User','undef') 
called at ./useradd.pl line 4
Can't call method "err" on an undefined value at 
/usr/local/lib/perl5/5.8.0/RT/Base.pm line 54.  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://pallas.eruditorum.org/pipermail/rt-devel/attachments/20030410/91322442/attachment.html


More information about the Rt-devel mailing list