Check if authentication table exists.
This commit is contained in:
parent
a122d4801b
commit
3764a80551
1 changed files with 16 additions and 13 deletions
|
|
@ -4,34 +4,37 @@ BEGIN {
|
|||
$configFile = "WebGUI.conf";
|
||||
$webguiRoot = "..";
|
||||
unshift (@INC, $webguiRoot."/lib");
|
||||
}
|
||||
|
||||
print "\n\n\nThis program converts the old userauthentication system to the new (pluggable) one.\n" .
|
||||
"It does NOT delete the old system so you can always go back to a stable WebGUI release.\n".
|
||||
"If you don't want this functionality you should delete the 'ldapURL', 'connectDN' and the 'identifier' columns ".
|
||||
"from the users table\n\n";
|
||||
|
||||
print "Opening WebGUI Session...";
|
||||
print "\n".
|
||||
"This program converts the old userauthentication system to the new (pluggable)\n".
|
||||
"one. It does NOT delete the old system so you can always use an older stable\n".
|
||||
"WebGUI release. If you don't want to return to the primitive days without\n".
|
||||
"pluggable authentication, you should delete the 'ldapURL', 'connectDN' and the\n".
|
||||
"'identifier' columns from the users table\n\n";
|
||||
}
|
||||
|
||||
use strict;
|
||||
use WebGUI;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Utility;
|
||||
|
||||
# Open a session for easy use of WebGUI::SQL
|
||||
#--- Open a session for easy use of WebGUI::SQL --------------------------
|
||||
print "Opening WebGUI Session...";
|
||||
WebGUI::Session::open($webguiRoot, $configFile);
|
||||
print "Ready\n\n";
|
||||
|
||||
# Create the authentication table
|
||||
my $sql;
|
||||
#--- Check if the authentication table already exists --------------------
|
||||
my @tables = WebGUI::SQL->buildArray("show tables");
|
||||
die "Table 'authentication' already exists!\n" if isIn('authentication', @tables);
|
||||
|
||||
#--- Create the authentication table -------------------------------------
|
||||
print "Creating authentication table...";
|
||||
my $sql = "create table authentication (userId int(11) not null, authMethod varchar(30) not null, fieldName varchar(128) not null, fieldData text, primary key (userId, authMethod, fieldName))";
|
||||
WebGUI::SQL->write($sql);
|
||||
print "OK\n\n";
|
||||
|
||||
# And go convert
|
||||
#--- And go convert ------------------------------------------------------
|
||||
my $sth = WebGUI::SQL->read("select * from users");
|
||||
|
||||
while (my %hash = $sth->hash) {
|
||||
print "Converting user $hash{username} (id: $hash{userId})";
|
||||
WebGUI::SQL->write("insert into authentication values ($hash{userId}, 'LDAP', 'ldapUrl', ". quote($hash{ldapUrl}) .")");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue