<div dir="ltr"><div><br></div>Hi list !<div><br></div><div>I want to set up a process to create a LDAP account automatically after admin validation.</div><div>Currently, to create an account, user open a ticket and we run an homemade bash script with the username as argument. It create the account, set some options, and return the password.</div>
<div>I want to automatize this task. The idea is to create three CF : Status, Username and Password. When an user create a ticket for a new LDAP account and if the admin agrees, he will set the CF-Username and valide the request by setting the CF-Status to "OK".</div>
<div>At this time, a scrip must be launched, call the bash script, set a random password, and send the credentials to user and close the ticket.</div><div><br></div><div>Also, for test purpose, I've created this basic bash script (/opt/rt4/bin/create_user.sh):</div>
<div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>/opt/rt4/bin/rt edit $1 set CF.{PASS}="Passwd"</div></div><div><div>/opt/rt4/bin/rt edit $1 set CF.{Validation}="Send"</div>
</div><div><div>exit 0</div></div></blockquote><div><br></div><div>And theses scrips :</div><div><br></div><div>CreateUser:</div><div>Custom condition :</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><div>my $Ticket = $self->TicketObj;</div></div><div><div>return 0 unless $self->TicketObj->FirstCustomFieldValue('Status') eq 'OK';</div></div><div><div>return 1;</div></div></blockquote><div>
Custom Action:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>my $ticket = $self->TicketObj;</div></div><div><div>my $id = $ticket->Id;</div></div><div><div>system("/opt/rt4/bin/create_user.sh $id >> /tmp/debug"); </div>
</div><div><div>return 1;</div></div></blockquote><div><br></div><div>SendCredentials:</div><div>Custom Condition :</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>my $Ticket = $self->TicketObj;</div>
</div><div><div>return 0 unless $self->TicketObj->FirstCustomFieldValue('Status') eq 'Send';</div></div><div><div>return 1;</div></div></blockquote><div>Action : Notify requestor and Cc</div><div>Template : Custom with credentials</div>
<div><br></div><div>When I set a the CF "Status" to OK, the scrip is correctly launched, and I see the first connection of the bash script is the system log :</div><div><div>Feb 3 12:08:58 bob RT: [10535] Successful login for Anthony from localhost</div>
</div><div><br></div><div>Then, apache did not respond during many seconds, and I see the second connection :</div><div><div>Feb 3 12:09:31 bob RT: [10534] Successful login for Anthony from localhost</div></div><div><br>
</div><div>And then, few seconds after :</div><div><div>Feb 3 12:09:50 bob RT: [10535] DBD::mysql::st execute failed: Lock wait timeout exceeded; try restarting transaction at /usr/local/share/perl/5.14.2/DBIx/SearchBuilder/Handle.pm line 589.</div>
<div>Feb 3 12:09:50 bob RT: [10535] RT::Handle=HASH(0x71041f8) couldn't execute the query 'SELECT * FROM Tickets WHERE id = ? FOR UPDATE' at /usr/local/share/perl/5.14.2/DBIx/SearchBuilder/Handle.pm line 602.#012#011DBIx::SearchBuilder::Handle::SimpleQuery(RT::Handle=HASH(0x71041f8), "SELECT * FROM Tickets WHERE id = ? FOR UPDATE", 28) called at /usr/local/share/perl/5.14.2/DBIx/SearchBuilder/Record.pm line 1234#012#011DBIx::SearchBuilder::Record::_LoadFromSQL(RT::Ticket=HASH(0x420fff0), "SELECT * FROM Tickets WHERE id = ? FOR UPDATE", 28) called at /opt/rt4/sbin/../lib/RT/Record.pm line 1605#012#011RT::Record::LockForUpdate(RT::Ticket=HASH(0x420fff0)) called at /opt/rt4/sbin/../lib/RT/Record.pm line 1641#012#011RT::Record::_NewTransaction(RT::Ticket=HASH(0x420fff0), "Type", "CustomField", "Field", 3, "OldReference", undef, "NewReference", RT::ObjectCustomFieldValue=HASH(0x422c5b8), ...) called at /opt/rt4/sbin/../lib/RT/Record.pm line 2034#012#011RT::Record::_AddCustomFieldValue(RT::Ticket=HASH(0x420fff0), "Field", RT::CustomField=HASH(0x4211c20), "Value", "wazaaaaa") called at /opt/rt4/sbin/../lib/RT/Record.pm line 1913#012#011RT::Record::AddCustomFieldValue(RT::Ticket=HASH(0x420fff0), "Field", RT::CustomField=HASH(0x4211c20), "Value", "wazaaaaa") called at /opt/rt4/share/html/REST/1.0/Forms/ticket/default line 403#012#011HTML::Mason::Commands::__ANON__("id", 28, "args", undef, "format", undef, "changes", HASH(0x41ed280)) called at /usr/local/share/perl/5.14.2/HTML/Mason/Component.pm line 138#012#011HTML::Mason::Component::run(HTML::Mason::Component::FileBased=HASH(0x420f990), "id", 28, "args", undef, "format", undef, "changes", HASH(0x41ed280), ...) called at /usr/local/share/perl/5.14.2/HTML/Mason/Request.pm line 1300#012#011eval {...} called at /usr/local/share/perl/5.14.2/HTML/Mason/Request.pm line 1295#012#011HTML::Mason::Request::comp(undef, undef, "id", 28, "args", undef, "format", undef, "changes", ...) called at /opt/rt4/share/html/REST/1.0/dhandler line 299#012#011HTML::Mason::Commands::__ANON__("pass"</div>
<div>Feb 3 12:09:50 bob RT: [10535] <rt-4.2.2-10535-1391425790-954.28-18-0@support.bob> #28/633 - Scrip 18 SendCredentials</div><div>Feb 3 12:09:50 bob RT: [10535] <rt-4.2.2-10535-1391425790-954.28-18-0@support.bob> sent To: anthony@test.localhost</div>
<div>Feb 3 12:10:04 bob RT: [10534] <rt-4.2.2-10534-1391425804-931.28-18-0@support.bob> #28/635 - Scrip 18 SendCredentials</div><div>Feb 3 12:10:04 bob RT: [10534] <rt-4.2.2-10534-1391425804-931.28-18-0@support.bob> sent To: anthony@test.localhost</div>
<div>Feb 3 12:10:05 bob RT: [10529] Use of uninitialized value in string eq at (eval 449) line 2.</div><div>Feb 3 12:10:05 bob RT: [10529] Use of uninitialized value in string eq at (eval 451) line 2.</div><div>Feb 3 12:10:05 bob RT: [10529] Use of uninitialized value in string eq at (eval 457) line 2.</div>
<div>Feb 3 12:10:05 bob RT: [10529] Use of uninitialized value in string eq at (eval 459) line 2.</div><div>Feb 3 12:10:05 bob RT: [10538] Malformed UTF-8 character (unexpected end of string) in string ne at /usr/share/perl/5.14/Locale/Maketext.pm line 538.</div>
</div><div><br></div><div>And in the ticket history:</div><div><span class="" style="width:10em;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;font-size:13px;line-height:16px">Mon Feb 03 06:08:57 2014</span><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;font-size:13px;line-height:16px"> </span><span class="" style="margin-left:1em;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;font-size:13px;line-height:16px"><span class="" style="font-weight:bold"><a href="https://support.brodard.me/User/Summary.html?id=33" style="color:inherit;text-decoration:none">Anthony</a></span><b> - </b><span style="color:rgb(34,34,34);font-family:arial;font-size:small;line-height:normal"><b>Status</b></span><b> changed to OK </b></span></div>
<div><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;width:10em">Mon Feb 03 06:09:50 2014</span><span style="background-color:rgb(239,239,239);font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif"> </span><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;margin-left:1em;font-weight:bold"><span class=""><a href="https://support.brodard.me/User/Summary.html?id=33" style="color:inherit;text-decoration:none">Anthony</a></span> - PASS Passwd added </span></div>
<div><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;width:10em">Mon Feb 03 06:09:50 2014</span><span style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif"> </span><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;font-weight:bold;margin-left:1em"><span class="">The RT System itself</span> - Outgoing email recorded -> Credentials</span></div>
<div><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;width:10em">Mon Feb 03 06:10:04 2014</span><span style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif"> </span><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;margin-left:1em"><span class="" style="font-weight:bold"><a href="https://support.brodard.me/User/Summary.html?id=33" style="color:inherit;text-decoration:none">Anthony</a></span><b> - </b><span style="color:rgb(34,34,34);font-family:arial;font-size:small;line-height:normal"><b>Status</b></span><b> OK changed to Send </b></span></div>
<div><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;width:10em">Mon Feb 03 06:10:04 2014</span><span style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif"> </span><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;font-weight:bold;margin-left:1em"><span class="">The RT System itself</span> - Outgoing email recorded -> Credentials</span></div>
<div><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;width:10em">Mon Feb 03 06:10:04 2014</span><span style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif"> </span><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;margin-left:1em"><span class="" style="font-weight:bold"><a href="https://support.brodard.me/User/Summary.html?id=33" style="color:inherit;text-decoration:none">Anthony</a></span><b> - </b><span style="color:rgb(34,34,34);font-family:arial;font-size:small;line-height:normal"><b>Status</b></span><b> Send deleted</b></span></div>
<div><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;width:10em">Mon Feb 03 06:10:05 2014</span><span style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif"> </span><span class="" style="font-size:13px;line-height:16px;color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;font-weight:bold;margin-left:1em"><span class=""><a href="https://support.brodard.me/User/Summary.html?id=33" style="color:inherit;text-decoration:none">Anthony</a></span> - PASS Passwd deleted </span></div>
<div><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif;font-size:13px;font-weight:bold;line-height:16px"><br></span></div><div>First, I don't understand why the credentials are sends two times, even when the Status is not "Send". Then, do you have an idea about the two last lines in ticket history (CF are reset) ? And finally, what seems wrong in my process, and what can cause theses troubles in my apache srv ?</div>
<div><br></div><div>Thanks!</div><div>Anthony</div></div>