<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7233.28">
<TITLE>Problem with the rt perl module and authentication</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<BR>

<P><FONT SIZE=2 FACE="Arial">I'm trying to run a script which uses the RT::Interface::CLI and I get the following error from the command line. Anyone get this error?   Below is the code using the perl interface and below that is and example call from the command line.  I believe that the problem is probably with GetCurrentUser() but I am not sure.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Thanks</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">The error is ….</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Couldn't load  from the users database.</FONT>

<BR><FONT SIZE=2 FACE="Arial"> (/opt/rt3/lib/RT/CurrentUser.pm:145)</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">--------------------------------------------------------------------------------------------------------------------</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">Here is a test script ….</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Arial">#!/usr/bin/perl -w</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">use lib ("/opt/rt3/local/lib","/opt/rt3/lib");</FONT>

<BR><FONT SIZE=2 FACE="Arial">use RT::Interface::CLI;</FONT>

<BR><FONT SIZE=2 FACE="Arial">use RT;</FONT>

<BR><FONT SIZE=2 FACE="Arial">use RT::Ticket;</FONT>

<BR><FONT SIZE=2 FACE="Arial">use RT::CurrentUser;</FONT>

<BR><FONT SIZE=2 FACE="Arial">use Getopt::Long;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">$queue = '';</FONT>

<BR><FONT SIZE=2 FACE="Arial">$body = '';</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">GetOptions ("queue=s" => \$queue,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "subject=s" => \$subject,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "owner=s" => \$owner,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "requestor=s" => \$requestor,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "priority=s" => \$priority,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "body=s" => \$body,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "AdminCc=s" => \$AdminCc,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "cc=s" => \$cc,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "RefersTo=s" => \$RefersTo,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "ReferredToBy=s" => \$ReferredToBy,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "DependsOn=s" => \$DependsOn,</FONT>

<BR><FONT SIZE=2 FACE="Arial">            "Parents=s" => \$Parents</FONT>

<BR><FONT SIZE=2 FACE="Arial">);</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial"># setting some defaults</FONT>

<BR><FONT SIZE=2 FACE="Arial">if ($queue eq '')</FONT>

<BR><FONT SIZE=2 FACE="Arial">{</FONT>

<BR><FONT SIZE=2 FACE="Arial">        print_usage();</FONT>

<BR><FONT SIZE=2 FACE="Arial">        exit (0);</FONT>

<BR><FONT SIZE=2 FACE="Arial">}</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">if ($body eq '')</FONT>

<BR><FONT SIZE=2 FACE="Arial">{</FONT>

<BR><FONT SIZE=2 FACE="Arial">        $body=' ';</FONT>

<BR><FONT SIZE=2 FACE="Arial">}</FONT>

<BR><FONT SIZE=2 FACE="Arial">RT::LoadConfig();</FONT>

<BR><FONT SIZE=2 FACE="Arial">RT::Init();</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">if ($owner eq '') {$owner = 'Nobody';}</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">my $CurrentUser = RT::Interface::CLI::GetCurrentUser();</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">use MIME::Entity;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">my $ticket = new RT::Ticket($CurrentUser);</FONT>

<BR><FONT SIZE=2 FACE="Arial">my $ticket_body = MIME::Entity->build(Data => $body,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                                     Type => 'text/plain');</FONT>

<BR><FONT SIZE=2 FACE="Arial">my %ticket_vals = ( Queue => $queue,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   Subject => $subject,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   Owner => $owner,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   Requestor => $requestor,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   InitialPriority => $priority,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   MIMEObj => $ticket_body,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   AdminCc => $AdminCc,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   Cc => $cc,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   'RefersTo' => $RefersTo,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   'ReferredToBy' => $ReferredToBy,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   'DependsOn' => $DependsOn,</FONT>

<BR><FONT SIZE=2 FACE="Arial">                   'MemberOf' => $Parents</FONT>

<BR><FONT SIZE=2 FACE="Arial">                 );</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">my ($id, $transaction_object, $err) = $ticket->Create(%ticket_vals);</FONT>

<BR><FONT SIZE=2 FACE="Arial">print $err . "\n" if $err;</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">--------------------------------------------------------------------------------------------------------------------</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">This is a test call of the script.</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">./test.pl -queue="Development" -subject="This is a test subject for test script" -owner='bob' -requestor='bob@bob.com' -priority=99 -body="This is the body of the ticket"</FONT></P>
<BR>
<BR>

</BODY>
</HTML>