This topic is locked

Validate users

3/28/2004 3:22:34 AM
ASPRunnerPro General questions
author

Hello,
I need to have 4 different access levels to my database

Guests: View all

Users type A: View all, Add in tables type A, Modify theirs

Users type B: View all, Add in tables type B, Modify theirs

Admin: **
Also database of users is a common database with another application, and I need only certain users to be able to access through the web application.
Guests and Admin is done by the ASPrunner Pro program

*The validation for the users to modify their own input is also in the program.
What I am missing is...

a) Validation for 'Users type A' to add and modify only to tables type A and so on for all other type of users....

b)Only users that have WEB ACCESS to be able to login at all through the web. I suppose a field in their records indication web access would do the trick for this, but I do not know how to modifiy the program.
Thank you,
Arbe

Sergey Kornilov 3/30/2004

Here is what you can do to implement it:

  1. Add a text field named UserType to Users table (table where you store usernames and passwords). Put in this field "TypeA" for the first users type and "TypeB" for the second users type. Add field named WebAccess (Yes/No) which will indicate if this user can login via Web.
  2. Modify SQL query that verifies username and password:
    strSQL = "select * from " & cLoginTable & " where " & AddWrappers(cUserNameField) &

    "='" & Replace(Trim(Request("username")),"'","''") & "' and " &  AddWrappers(cPasswordField) &

    "='" & Replace(Trim(Request("password")),"'","''") & "'and WebAccess=true"


3. Modify login page (login.asp) to read UserType and save it to Session variable when user logs in. Insert this code right before redirecting user to list or menu page.

Session("UserType") = rs("UserType")


4. Insert the following snippet of code in the beginning of CheckSecurity function in the Table A list.asp file:

if Session("UserType")="TypeA" then

    CheckSecurity = True

else

    CheckSecurity = False

end if

Exit Function


5. Insert the following snippet of code in the beginning of CheckSecurity function in the Table B list.asp file:

if Session("UserType")="TypeB" then

    CheckSecurity = True

else

    CheckSecurity = False

end if

Exit Function


I hope this helps.

501055 3/31/2004

thanks for the reply!

I am going to try it out and I will let you know how it goes.