Thanks to Ruslan and his piece of code i was able to right this script. It will be helpfull to anyone upgrading to RT 3.4.5 , and people who use to rt database to authentacate users for other pieces of software. It seems RT 3.4.5 uses an MD5 HEX encoding system, but for backwards compatability it can read MD5 base64 encoded passwords. However as users log into the new system the passwords are re-encoded and stored in the new HEX format. This script will change all the passwords to HEX and leave any blank passwords alone. Hope this helps :)
 
#!/usr/bin/perl
# load module
use DBI;
use MIME::Base64 qw();
use bytes;
#query
my $query = qq(
SELECT *
From Users
WHERE CHAR_LENGTH(Password)< 32 AND (CHAR_LENGTH(Password) != 0) AND (CHAR_LENGTH(Password) != 13)
);
# connect
my $dbh = DBI->connect("DBI:mysql:database=rt3;host=localhost", "root", "", {'RaiseError' => 1});
my $sth = $dbh->prepare($query);
$sth->execute();
# iterate through resultset
# print values
while(my $ref = $sth->fetchrow_hashref()) {
$old_encoded_pwd = $ref->{'Password'};
my $md5 = MIME::Base64::decode($old_encoded_pwd);
$md5 =~ s/(.)/sprintf "%02x",ord($1)/gmse;
print "User: $ref->{'Name'}\n";
print "Password: $ref->{'Password'}\n";
print "New Password: '$md5'\n";
# execute INSERT query
my $rows = $dbh->do("update Users SET Password= '$md5' WHERE Name='$ref->{Name}';");
print "$rows row(s) affected\n";
print "----------\n";
}
# clean up
$dbh->disconnect();


Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.
_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com


We're hiring! Come hack Perl for Best Practical: 
http://bestpractical.com/about/jobs.html

Reply via email to