The mgiAuthenticateDB Tag
Tag Behavior
The mgiAuthenticateDB tag password-protects individual pages
by groups of users with database-driven administration.
Tag Syntax
The mgiAuthenticateDB tag has no required parameters and five
optional parameters. In addition, the mgiAuthenticateDB tag has
required and optional parameters for specific modes. The tag
form is:
<mgiAuthenticateDB group="Name" mode="Mode"
useCookies="Yes/No" expireDate="Date" expireTime="Time">
Required Parameters:
Optional Parameters:
- group="Name" where "Name" is the
name of the user group that has login and password access to
the page. All other groups and users will be denied access, even
if they have a correct login and password in the database with
another group. If no group is specified, then all groups are
granted password access to the page.
- mode="Mode" where "Mode" is "Admin",
"AddRecord" or "ValidateLogin".
The "Admin" mode creates a web administration interface
for adding, modifying and deleting records from the authentication
database. (When the "Admin" mode
parameter is present, all other parameters are ignored.)
The "AddRecord" mode adds records to the authentication
database. (If the mode parameter is set
to "AddRecord", then the login, password, and group
parameters are required - see parameter descriptions below.)
The "ValidateLogin" mode checks a login against those
in the authentication database. If a login is already present
in the authentication database (and is NOT unique), then the
value "Yes" is displayed. If a login is not present
in the authentication database (and is unique), then the value
"No" is displayed. (If the mode
parameter is set to "ValidateLogin", then the login
parameter is required - see parameter description below.)
- useCookies="Yes" or "No" where
"Yes" indicates that cookies containing a user's Login
and Password are automatically set and retrieved and "No"
indicates that cookies are not set and retrieved. The default
is "No". If the useCookie parameter
is "Yes", then the expireDate and expireTime parameters
are required.
- expireDate="Date" where "Date"
is the expiration Date of the cookie in the format mm-dd-yyyy
(e.g. 12-31-2001).
- expireTime="Time" where "Time"
is the expiration Time of the cookie in military format hh:mm
(e.g. 14:30).
AddRecord Mode Required Parameters:
- login="Name" where "Name" is the
case-sensitive login ID that is added to the authentication database.
- password="Password" where "Password"
is the case-sensitive alpha-numeric password for the specified
login.
AddRecord Mode Optional Parameters:
- group="Group" where "Group" is
the authentication group that the specified login belongs to.
- startDate="Date" where "Date"
is the first day the specified login and password is valid. The
syntax of the date must be 4-digit year, 2-digit month, 2-digit
day (yyyymmdd). For example, 19991101 is 1 November 1999. The
startDate parameter can be used in conjunction with the endDate
parameter to specify a definite time frame or entered alone to
specify a start date without an expiration. If the startDate
parameter is not included, the login and password will be valid
immediately. Note: this parameter will
only function with Authentication databases created using or
after MGI version 1.4. All databases created under previous versions
will continue to function, but will not include this option.
- endDate="Date" where "Date" is
the last day the specified login and password is valid. The syntax
of the date must be 4-digit year, 2-digit month, 2-digit day
(yyyymmdd). For example, 20001101 is 1 November 2000. The endDate
parameter can be used in conjunction with the startDate parameter
to specify a definite time frame or entered alone to specify
an expiration with an immediate start date. If the endDate parameter
is not included, the login and password do not expire. Note: this parameter will only function with
Authentication databases created using or after MGI version 1.4.
All databases created under previous versions will continue to
function, but will not include this option.
ValidateLogin Mode Required Parameter:
- login="Name" where "Name" is the
case-sensitive login ID that is checked for uniqueness against
the existing logins in the specified authentication group.
ValidateLogin Mode Optional Parameter:
- group="Group" where "Group" is
the authentication group to use for validating logins. If the
group parameter is not included, the login is validated for all
groups.
Example Usage and Output
<mgiAuthenticateDB group="Web">
In this example, a visitor will log in to the page containing
the mgiAuthenticateDB tag and enter his login and password in
an authentication dialogue box. After the correct login and password
are entered, the page is displayed. If the incorrect login and
password are entered, an error page is displayed.
Example Admin Mode Usage and Output:
<mgiAuthenticateDB mode="Admin">
The administration mode of the authentication database presents
a simple interface for entering logins, passwords, and groups.
The database administration includes search, add, modify, and
delete options. When entering multiple groups for a user, separate
the groups by commas.
Example ValidateLogin Mode Usage and Output:
In this example, subscribers to a web-based service are allowed
to choose their own login and password. Visiting subscribers
enter their login and password choices in a subscription form,
then the login is checked for uniqueness (using an embedded mgiFieldContent
tag in the mgiAuthenticateDB tag) and the returned value ("Yes"
or "No") is set in a page variable. Finally, an mgiIf
tag checks the value of the cookie and displays the appropriate
message.
<mgiset name="Validate">
<mgiAuthenticateDB mode="validateLogin"
login={mgiPostArgument name="Username"} group="Subscriber">
</mgiset>
<mgiConditional lhs={mgiGet name="Validate"}
relationship="equals" rhs="yes">
<P>Your username already exists. Please choose another username.
Both the Username and Password are case-sensitive, therefore you
may want to try the same username with different capitalization.
<mgiElse>
<form action="register.html" method="post">
<P>Your username has been accepted. Please click the button
below to complete your registration.
<input type="hidden" name="Login"
value="<mgiPostArgument name="Username">">
<input type="hidden" name="Password"
value="<mgiPostArgument name="Password">">
<mgiButton name="Register">
</form>
</mgiConditional>
If a login is not unique, then a subscriber will see the following:
- Your username already exists. Please choose another username.
Both the Username and Password are case-sensitive, therefore
you may want to try the same username with different capitalization.
If a login is unique, then a subscriber will see the following:
- Your username has been accepted. Please click the button
below to complete your registration.
-
Example AddRecord Mode Usage and Output:
<mgiAuthenticateDB mode="addRecord"
login={mgiFieldContent name="Login"}
password={mgiFieldContent name="Password"}
group="Subscriber">
In this example, subscribers to a web-based service have chosen
a unique login and password using a form (as in the example above
for the ValidateLogin mode). Subscribers' logins and passwords
are dynamically added to the authentication database (using embedded
mgiFieldContent tags) with access to the "Subscriber"
group. When parsed, the AddRecord mode of the mgiAuthenticateDB
tag does not display any text on the page.
Suggested Usage
- Password Protection
- Subscription Services
|