Search code examples
asp-classic

If not determined user, show restriction page, Else, show desired page


i'm stuck at my job dealing with an issue new to me, you see, i need to check that only certain users can access a determined page rather than all of them, so i'm trying an "if not" command but it's not working, how can i solve this?

basically what i need is that if is not a determined user shows a page that says "hey, you're not allowed here" and if it is such user shows a page that says "welcome to this page" or something

If not user_unique_id = 287 OR 809 OR 833 OR 829 OR 837 OR 831 then 

     response.redirect "Authorized_users_only.asp"
Else
    response.redirect "Desired_page.asp"
End If

the error i'm getting is it is only allowing me one user, usually the first one i place, the rest doesn't let them into the desired page


Solution

  • You need to repeat your test for each ID. For example:

    If not (user_unique_id = 287 OR user_unique_id = 809 OR...) then
    

    Try this variation instead:

    Select Case user_unique_id
      Case 287, 809, 833, 829, 837, 831
      response.redirect "Desired_page.asp"
      Case Else
      response.redirect "Authorized_users_only.asp"
    End select
    

    Ideally, you should use a database where user rights are defined, or you'll need to modify your code everytime a new user gets access or someone leaves...