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";
|
$configFile = "WebGUI.conf";
|
||||||
$webguiRoot = "..";
|
$webguiRoot = "..";
|
||||||
unshift (@INC, $webguiRoot."/lib");
|
unshift (@INC, $webguiRoot."/lib");
|
||||||
}
|
print "\n".
|
||||||
|
"This program converts the old userauthentication system to the new (pluggable)\n".
|
||||||
print "\n\n\nThis program converts the old userauthentication system to the new (pluggable) one.\n" .
|
"one. It does NOT delete the old system so you can always use an older stable\n".
|
||||||
"It does NOT delete the old system so you can always go back to a stable WebGUI release.\n".
|
"WebGUI release. If you don't want to return to the primitive days without\n".
|
||||||
"If you don't want this functionality you should delete the 'ldapURL', 'connectDN' and the 'identifier' columns ".
|
"pluggable authentication, you should delete the 'ldapURL', 'connectDN' and the\n".
|
||||||
"from the users table\n\n";
|
"'identifier' columns from the users table\n\n";
|
||||||
|
}
|
||||||
print "Opening WebGUI Session...";
|
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use WebGUI;
|
use WebGUI;
|
||||||
use WebGUI::SQL;
|
use WebGUI::SQL;
|
||||||
use WebGUI::Session;
|
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);
|
WebGUI::Session::open($webguiRoot, $configFile);
|
||||||
print "Ready\n\n";
|
print "Ready\n\n";
|
||||||
|
|
||||||
# Create the authentication table
|
#--- Check if the authentication table already exists --------------------
|
||||||
my $sql;
|
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...";
|
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))";
|
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);
|
WebGUI::SQL->write($sql);
|
||||||
print "OK\n\n";
|
print "OK\n\n";
|
||||||
|
|
||||||
# And go convert
|
#--- And go convert ------------------------------------------------------
|
||||||
my $sth = WebGUI::SQL->read("select * from users");
|
my $sth = WebGUI::SQL->read("select * from users");
|
||||||
|
|
||||||
while (my %hash = $sth->hash) {
|
while (my %hash = $sth->hash) {
|
||||||
print "Converting user $hash{username} (id: $hash{userId})";
|
print "Converting user $hash{username} (id: $hash{userId})";
|
||||||
WebGUI::SQL->write("insert into authentication values ($hash{userId}, 'LDAP', 'ldapUrl', ". quote($hash{ldapUrl}) .")");
|
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