Monday, April 16, 2007

How to AutoGen Users and passwd in RT3

How to auto generate users and passwords while submitting tickets through email in Request Tracker 3.


Add this code to AutoReply Template:

{
*RT::User::GenerateRandomNextChar = \&RT::User::_GenerateRandomNextChar;

if (($Transaction->CreatorObj->id != $RT::Nobody->id) &&
(!$Transaction->CreatorObj->Privileged) &&
($Transaction->CreatorObj->__Value('Password') eq '*NO-PASSWORD*')
) {

my $user = RT::User->new($RT::SystemUser);
$user->Load($Transaction->CreatorObj->Id);
my ($stat, $pass) = $user->SetRandomPassword();

if (!$stat) {
$OUT .=

"An internal error has occurred. RT was not able to set a password for you.
Please contact your local RT administrator for assistance.";

}

$OUT .= "
You can check the current status and history of your requests at:

".$RT::WebURL."

When prompted, enter the following username and password:

Username: ".$user->Name."
Password: ".$pass."

";
}
}


Clearing Mason Cache:

 shell> rm -rf /opt/rt3/var/mason_data/obj/*

No comments: