Gossamer Forum
Home : Products : DBMan : Installation :

Large number of passwords

Quote Reply
Large number of passwords
Is there a way to load a large number of authorized users/passwords. I have about 300 that I need to add.
Quote Reply
Re: Large number of passwords In reply to
What format are they in now?


------------------
JPD






Quote Reply
Re: Large number of passwords In reply to
Delimited ascii text.
Quote Reply
Re: Large number of passwords In reply to
How is it delimited? Tabs? Commas? Is each username/password pair on a separate line? Are the passwords encrypted?


------------------
JPD






Quote Reply
Re: Large number of passwords In reply to
List is delimited with pipes | and passwords are text. I want them to be encrypted similar to what happens when you manually add users through the admin option.

Thanks
Mark
Quote Reply
Re: Large number of passwords In reply to
Okay. Now we're gettin' somewhere. Smile

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! Smile


------------------
JPD






Quote Reply
Re: Large number of passwords In reply to
This converter is picking up only the first character in the user portion. If it helps the data looks like:

123456|01011960

MD
Quote Reply
Re: Large number of passwords In reply to
I made an error.

Instead of

Code:
@data=split '|',$line;

use

Code:
@data=split "\|",$line;



------------------
JPD






Quote Reply
Re: Large number of passwords In reply to
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 Smile I have another question, but will start another thread for it.

MD