I recommend a slightly different solution.
You must assure that the authorize/authenticate method makes the decision returning only results. This puts your password package in jepordy less often. Assuring that the decision making process remains in the authorization method standardizes the rules and keeps the implementation in one place.
Change your query to something more along the lines of:[tt]
SELECT AccessLevel FROM Table WHERE UserId= UID AND pwd = PWD[/tt]
An empty recordset means the user is not authorized, id or pwd is wrong. A list means the user has varying degrees of access. Expecyt only 1 row in normal conditions.
Level based Authorization provides a specialized model of authentication. Successful authentication yields varying degrees of access rights. I suggest including fields to your user table, one for the application the other Access level. Using this enables listing Access Levels by User and Application.
An Application table identifying the access levels required by each application function should help with the management of the relationship.
You can build this with two objects, User and Function.
Watch out for reserved words or namespace collisions.
The User object's key members are Authenticate and AccessLevel. The Function object provides Authorize. Other names for this might be Attach or Bind.
A desirable coding sequence might look like this:
[tt]
SET oUser = new ClassBasedOnUser
oUser.Authenticate(UserId, Password)
SET oFunction = new ClassBasedOnFunction
oFunction.Attach (oUser) ' Set Objects performance level
oFunction.Execute ' Do level appropriate work
[/tt]
Attach can do all the work, building the object with the members appropriate to the access level. Query the database for the list of functions the user is authorized to use and have attach load the objects that implement them.
[tt]SELECT FunctionName from Application where USER = UserId AND AccessLevel < UserLevel[/tt]
Or, the level sensitive members, like Execute, can handle the access level variations themselves. Both ways have merits and penalties.
Wil Mead
wmead@optonline.net