On Thu, Mar 24, 2011 at 03:20:12PM +0100, Sergio Cubero wrote: > I want create user with perl script, but don't working. > Can you help me?
How doesn't it work? Please describe the failure and provide the logs. -kevin > #!/usr/bin/perl > use lib ("/usr/local/rt-3.8.2/lib/"); > use RT::Interface::CLI qw(CleanEnv); > use RT; > RT::LoadConfig(); > RT::Init(); > use RT::Ticket; > use RT::CurrentUser; > use RT::CustomField; > use RT::Action::Generic; > use RT::Transaction; > use MIME::Entity; > package RT::Action::MyAction; > use base qw(RT::Action::Generic); > use RT::Authen::ExternalAuth::LDAP; > use RT::Authen::ExternalAuth::DBI; > > my $user = 'username'; > my $mail = 'usern...@domain.com'; > RT->Config->Get('WebExternalAuto'); > > $session->{'CurrentUser'} = RT::CurrentUser->new(); > $session->{'CurrentUser'}->Load($user); > > my $UserObj = RT::User->new($RT::SystemUser); > print $UserObj."\n"; > my ($val, $msg) = $UserObj->SetName($user); > > my ($val, $msg) = > > $UserObj->Create( > %{ref($RT::AutoCreate) ? $RT::AutoCreate : {}}, > Name => $user, > Gecos => $user, > _RecordTransaction => 1, > EmailAddress => $mail, > RealName => 'User USer', > Comments => 'user LDAP', > WorkPhone => 'phone, > Address1 => 'streetAddress', > City => 'l', > State => 'st', > Zip => 'postalCode', > Country => 'co' > ); > $RT::Logger->info("Autocreated authenticated user " . $UserObj->Name . > " (" . $UserObj->Id . ")\n"); > > $session{'CurrentUser'}->Load($user) if $UserObj->Id; > $RT::Logger->error( "No puedo crear el usuario $user: $msg" ); > > if(RT::Authen::ExternalAuth::UserExists($user)){ print "EXISTS";} > else {print "NO EXISTS";} > > > > $RT::Logger->info( "Autocreated external user", > $UserObj->Name, > "(", > $UserObj->Id, > ")"); > > $RT::Logger->debug("Loading new user (", > $username, > ") into current session"); > $session->{'CurrentUser'}->Load($username); > > >
pgpTlkH5ivltx.pgp
Description: PGP signature