Is there a way to load a large number of authorized users/passwords. I have about 300 that I need to add.
Apr 17, 2000, 10:46 AM
Veteran / Moderator (8669 posts)
Apr 17, 2000, 10:46 AM
Post #6 of 9
Views: 3151
Okay. Now we're gettin' somewhere.
Save the following in your DBMan directory as convert.cgi. Be sure to note the comment lines and make changes as necessary.
# Change the line above to match your path to perl
$db_script_path = ".";
# change the line below to the name of your current password file
$password_file = $db_script_path . "/password.txt";
# Full path and file name of the password file.
$auth_pw_file = $db_script_path . "/default.pass";
# Permissions for every user (View, Add, Delete, Modify, Admin), 1 = enable, 0 = disable.
@auth_signup_permissions = (1,1,1,1,0);
open (PASS, "<$password_file") or
&cgierr("error in convert. unable to open password file: $password_file.\nReason: $!");
@lines=<PASS>;
close PASS;
srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
open (PASS, ">$auth_pw_file") or
&cgierr("error in convert. unable to open password file: $auth_pw_file.\nReason: $!");
foreach $line (@lines) {
@data=split '|',$line;
my @salt_chars = ('A' .. 'Z', 0 .. 9, 'a' .. 'z', '.', '/');
my $salt = join '', @salt_chars[rand 64, rand 64];
my $encrypted = crypt($data[1], $salt);
my $permissions = join (":", @auth_signup_permissions);
print PASS "$data[0]:$encrypted:$permissions\n";
}
close PASS;
chmod 0666, $auth_pw_file;
print "Content-type: text/html\n\n
<html><head><title>Passwords Converted</title><head>
<body>Your passwords were converted</body></html>";
sub cgierr {
# --------------------------------------------------------
# Displays any errors
if (!$html_headers_printed) {
print "Content-type: text/html\n\n";
$html_headers_printed = 1;
}
print "<PRE>\n\nCGI ERROR\n==========================================\n";
$_[0] and print "Error Message : $_[0]\n";
$0 and print "Script Location : $0\n";
$] and print "Perl Version : $]\n";
print "\n</PRE>";
exit -1;
}
Set the permission to 755 on convert.cgi and run it from your browser --
http://www.server.com/cgi-bin/dbman/convert.cgi
When you see the page that says, "Your passwords were converted," you'll be all done.
Be sure to delete the convert.cgi script from your directory after you finish with it. You don't want to run it a second time!
------------------
JPD
Save the following in your DBMan directory as convert.cgi. Be sure to note the comment lines and make changes as necessary.
Code:
#!/usr/local/bin/perl # Change the line above to match your path to perl
$db_script_path = ".";
# change the line below to the name of your current password file
$password_file = $db_script_path . "/password.txt";
# Full path and file name of the password file.
$auth_pw_file = $db_script_path . "/default.pass";
# Permissions for every user (View, Add, Delete, Modify, Admin), 1 = enable, 0 = disable.
@auth_signup_permissions = (1,1,1,1,0);
open (PASS, "<$password_file") or
&cgierr("error in convert. unable to open password file: $password_file.\nReason: $!");
@lines=<PASS>;
close PASS;
srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
open (PASS, ">$auth_pw_file") or
&cgierr("error in convert. unable to open password file: $auth_pw_file.\nReason: $!");
foreach $line (@lines) {
@data=split '|',$line;
my @salt_chars = ('A' .. 'Z', 0 .. 9, 'a' .. 'z', '.', '/');
my $salt = join '', @salt_chars[rand 64, rand 64];
my $encrypted = crypt($data[1], $salt);
my $permissions = join (":", @auth_signup_permissions);
print PASS "$data[0]:$encrypted:$permissions\n";
}
close PASS;
chmod 0666, $auth_pw_file;
print "Content-type: text/html\n\n
<html><head><title>Passwords Converted</title><head>
<body>Your passwords were converted</body></html>";
sub cgierr {
# --------------------------------------------------------
# Displays any errors
if (!$html_headers_printed) {
print "Content-type: text/html\n\n";
$html_headers_printed = 1;
}
print "<PRE>\n\nCGI ERROR\n==========================================\n";
$_[0] and print "Error Message : $_[0]\n";
$0 and print "Script Location : $0\n";
$] and print "Perl Version : $]\n";
print "\n</PRE>";
exit -1;
}
Set the permission to 755 on convert.cgi and run it from your browser --
http://www.server.com/cgi-bin/dbman/convert.cgi
When you see the page that says, "Your passwords were converted," you'll be all done.
Be sure to delete the convert.cgi script from your directory after you finish with it. You don't want to run it a second time!
------------------
JPD
Apr 18, 2000, 10:21 AM
Novice (7 posts)
Apr 18, 2000, 10:21 AM
Post #9 of 9
Views: 3180
OK, that didn't seem to help. On a suggestion from a co-worker, I changed the line to read:
@data=split(/,/,$line);
and changed the delimeter to a comma. This worked. Thanks for your help, you saved me a lot of time I have another question, but will start another thread for it.
MD
@data=split(/,/,$line);
and changed the delimeter to a comma. This worked. Thanks for your help, you saved me a lot of time I have another question, but will start another thread for it.
MD