Here's where we find out what's different about your server.
Some examples:
@DBM = (DBType => 'DBM',
DB => '.htpasswd',
Server => 'apache');
$user = new HTTPD::UserAdmin @DBM;
This creates an object who's database is a DBM file named
'.htpasswd', in a format that the Apache server understands.
@Text = (DBType => 'Text',
DB => '.htpasswd',
Server => 'ncsa');
$user = new HTTPD::UserAdmin @Text;
This creates an object whose database is a plain text file
named '.htpasswd', in a format that the NCSA server understands.
@SQL = (DBType => "SQL",
Host => "", #server hostname
Port => "", #server port
DB => "www", #database name
User => "", #database login name
Auth => "", #database login password
Encrypt => "crypt", #encryption method
Driver => "mSQL", #driver for DBI
Server => "apache", #HTTP server type, not required
UserTable => "www-users", #table with field names below
NameField => "user", #field for the name
PasswordField => "password", #field for the password
);
$user = new HTTPD::UserAdmin @SQL;
This creates an object who's mSQL database is named 'www',
with a schema that the Apache server (extention) understands.
Full list of constructor attributes:
Note: Attribute names are case-insensitive
DBType - The type of database, one of 'DBM', 'Text', or
'SQL' (Default is 'DBM')
DB - The database name (Default is '.htpasswd' for DBM
& Text databases)
Server - HTTP server name (Default is the generic
class, that works with NCSA, Apache and possibly others)
Note: run 'perl t/support.t matrix' to see what support is
currently availible
Encrypt - One of 'crypt', 'MD5', or 'none' (no
encryption. Defaults to 'crypt'
Locking - Boolean, Lock Text and DBM files (Default is
true)
Path - Relative DB files are resolved to this value
(Default is '.')
Debug - Boolean, Turn on debug mode
Flags - The read, write and create flags. There are
four modes: rwc - the default, open for reading, writing and
creating. rw - open for reading and writing. r - open for
reading only. w - open for writing only.
Specific to DBM files:
DBMF - The DBM file implementation to use (Default is
'NDBM')
Mode - The file creation mode, defaults to '0644'
Specific to DBI: We talk to an SQL server via Tim Bunce's DBI
interface. For more info see:
http://www.hermetica.com/technologia/DBI/
Host - Server hostname
Port - Server port
User - Database login name
Auth - Database login password
Driver - Driver for DBI (Default is 'mSQL')
UserTable - Table with field names below
NameField - Field for the name (Default is 'user')
PasswordField - Field for the password (Default is
'password')
From here on out, things should look the same for
everyone.
Add a user.
Fails if $username exists in the
database
if($user->add('dougm', 'secret')) {
print "You have the power!\n";
}
You may need to pass additional fields, such as the user's
real name. This depends on your server of course.
$user->add('JoeUser', 'try2guess', '', 'Joseph A. User');
You can also pass a set of field name/value pairs in the form
of a hash ref. Example
$user->add('JoeUser','try2guess','',
{'Name'=>'Joseph A. User','Credit_limit'=>2000});