SQLAuth External Authentication Module for DMail
An external authentication module that allows DMail to do user lookups
on a MySQL Database.
Installing SQLAuth
When you download SQLAuth or look for it in your DMail distribution,
you should find two files:
unix |
nt |
sqlauth
sqlauth.ini |
sqlauth.exe
sqlauth.ini |
Place these files into your dmail directory and update dmail.conf to point to this
external module.
e.g. on UNIX
authent_method external
authent_process /usr/local/dmail/auth
and on Windows:
authent_method external
authent_process c:\dmail\auth
Then you must edit the sqlauth.ini file so that it points to your
MySQL server. More details on this step are provided on the rest of this
page.
And then RESTART both DSMTP and DPOP.
NB: you must RESTART both DSMTP and DPOP when ever you change your
sqlauth.ini file, as they spawn copies of SQLAuth which only reads sqlauth.ini
at startup.
And that is it. For details of other External Authentication Settings see
the User Administration section of the DMail Manual.
SQLAuth requires a mysql database which is setup and working.
The database that is setup must
have a username and a password that is encrypted using the mysql command PASSWORD(). You
can either create a new database/table for SQLAuth or use a current database that has
usernames and passwords.
New DataBase:
Below are instructions on how to setup a brand new database and table to work with
SQLAuth, with all of the features that SQLAuth provides.
CREATE DATABASE maildb
USE maildb;
CREATE TABLE maildb (
username CHAR(128) binary DEFAULT '' NOT NULL,
passwd CHAR(128) DEFAULT '*' NOT NULL,
forward CHAR(255) DEFAULT '',
quota CHAR(20) DEFAULT '',
mailmask CHAR(18) DEFAULT '0.0.0.0' NOT NULL,
maildrop CHAR(255),
PRIMARY KEY (username)
);
To insert a brand new account into this account using your sql the command is:
INSERT INTO maildb VALUES
('test@test.org', PASSWORD('test'), '', '100k',
'0.0.0.0','/usr/spool/mail/test');
This will create a user called test@test.org with
the username of test.
To manually remove a user the command is:
DELETE FROM maildb WHERE username='test@test.org'
The inserting and deleting of users is taken care of by the SQLAuth, the above is to
show how you would manually do this.
The ini settings for the above would look like the following:
mysql_server your.sql.server
mysql_login login
mysql_password password
domain your.default.domain
mysql_mail_user_db maildb
mysql_mail_user_table maildb
field_username username
field_password passwd
field_forward forward
field_quota quota
field_mailmask mailmask
field_maildrop maildrop
Using Current DataBase:
You already have an existing database that you wish to use then as long as the
usernames are unique and the password field is encrypted using the PASSWORD() mysql
command, then you should be able to just change the ini settings to point to this
database, table and field label names.
eg. If you have a database called 'accounts' and a table called 'mail_users'
that stores all sorts of information but has the username field names 'name'
and the password field called 'pwd' then the ini settings that you
required are:
mysql_server your.sql.server
mysql_login login
mysql_password password
domain your.default.domain
mysql_mail_user_db accounts
mysql_mail_user_table mail_users
field_username name
field_password pwd
If you have the ability to also store the mail quota or forwarding then you can add
these ini settings as well.
ie. field_forward forward
field_quota quota
Check Install
Once SQLAuth is install the next step, it is best to then check that the SQLAuth is
working correctly. You will need to run SQLAuth from the command line and try the
following.
NOTE: C: - Client, S: - Server
./auth
C: set test_account password
S: +OK 'test_account@test.org' has been added to database
C: set test_fwd password fwd="test_account@domain1"
S: +OK 'test_account@test.org' has been added to database
C: set test_quota password quota="100k"
S: +OK 'test_account@test.org' has been added to database
C: set test password fwd="test_account@domain1" quota="100k"
S: +OK 'test_account@test.org' has been added to database
C: search *
S: +DATA test_quota@test.org config 0 quota="100k"
S: +DATA test_fwd@test.org config 0 fwd="test_account@domain1"
S: +DATA test_account@test.org config
S: +DATA test@test.org config 0 fwd="test_account@domain1"
quota="100k"
S: +OK Search Completed 4 items found
C: lookup test_quota
S: +OK test_quota@test.org config 0 quota="100k"
C: lookup test
S: +DATA test@test.org config 0 fwd="test_account@domain1"
quota="100k"
C: check test password
S: +OK test@test.org config 0 fwd="test_account@domain1" quota="100k"
C: check test incorrect
S: -ERR test@test.org password wrong or not a valid user
C: del test
S: +OK 'test@test.org' has been deleted
C: del test_account
S: +OK 'test_account@test.org' has been deleted
C: del test_quota
S: +OK 'test_quota@test.org' has been deleted
C: del test_fwd
S: +OK 'test_fwd@test.org' has been deleted
The acutal response back with quota and fwd might vary if the mysql database does not
have quotas or fwd setup. To get display the complete list SQLAuth supports enter the
command:
help
Information about the protocol being used can be seen at the link:
http://netwinsite.com/dmail/authprot.htm
Label |
Example |
Default |
Explanation |
debug |
true |
false |
Enables verbose debug output. |
domain |
your.default.domain |
none |
This is default domain that is appended to any username that does not already have a
domain setting attached. |
field_username |
user |
username |
The label of the username field in your table. |
field_password |
password |
passwd |
The label of the password field in your table. |
field_forward |
fwd |
forward |
The label of the forward field in your table. This is the fowarding information that
DMail uses to determine what it forwards the EMail to. |
field_quota |
quota |
none |
The label of the quota field in your table. This is the disk quota the user has.
ie. 100k, 10M |
field_mailmask |
mailmask |
none |
The label of the mailmask field in your table. This is the IP mask that SQLAuth checks
against the from IP of the user. This forces the user to use only the specified IP. |
field_maildrop |
maildrop |
none |
The label of the maildrop field in your table. This is the location where dmail will
drop the user mail files. |
log_path |
sqlauth.log |
auth.log |
This is the sqlauth log file. |
mysql_server |
your.sql.server |
none |
This is the IP or name of the computer hosting hte mysql server. |
mysql_login |
username |
none |
This is the username that has access to the correct database and table that stores the
usernames and passwords. |
mysql_password |
password |
none |
This is the password that is required and used in conjuction with mysql_login. |
mysql_mail_user_db |
user_data |
maildb |
This is the database name where the mail usernames are stored. |
mysql_mail_user_table |
users_list |
maildb |
This is the table name that is within the mail user database that has the user
details. |
mysql_mail_uid |
99 |
0 |
This is the unique mail ID. |