restrict access to page based on querystring value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?R1ROMTcwNzc3?=

    restrict access to page based on querystring value

    Hi there, I've got the standard Dreamweaver restrict access to page behaviour
    below –

    <%
    ' *** Restrict Access To Page: Grant or deny access to this page
    MM_authorizedUs ers="1,2,3"
    MM_authFailedUR L="index.asp"
    MM_grantAccess= false
    If Session("MM_Use rname") <"" Then
    If (false Or CStr(Session("M M_UserAuthoriza tion"))="") Or _
    (InStr(1,MM_aut horizedUsers,Se ssion("MM_UserA uthorization")) >=1) Then
    MM_grantAccess = true
    End If
    End If
    If Not MM_grantAccess Then
    MM_qsChar = "?"
    If (InStr(1,MM_aut hFailedURL,"?") >= 1) Then MM_qsChar = "&"
    MM_referrer = Request.ServerV ariables("URL")
    if (Len(Request.Qu eryString()) 0) Then MM_referrer = MM_referrer & "?" &
    Request.QuerySt ring()
    MM_authFailedUR L = MM_authFailedUR L & MM_qsChar & "accessdeni ed=" &
    Server.URLEncod e(MM_referrer)
    Response.Redire ct(MM_authFaile dURL)
    End If
    %>
    It restricts access to the page based upon the following values –

    MM_Username
    MM_UserAuthoriz ation

    I believe that is checking to see whether MM_Username exists and if so
    checking to see if the MM_UserAuthoriz ation value is either 1, 2 or 3

    I the event that both exist access is granted, in the event that one or
    neither exist it redirects the user to MM_authFailedUR L (index.asp)

    What I would like to do is build a similar behaviour, but that only checks
    one value, so instead of checking MM_Username & MM_UserAuthoriz ation it
    checks to see whether the variable ACC (which is sent through
    Request.QuerySt ring) equals either –

    Occ User
    Reg User
    Reg User5
    Reg User10
    Multi User

    And in the event that ACC as one of the values above Access is granted, in
    the event that this is not the case the user is redirected to info.asp.



    Any ideas on how to do this would be great -

    Thanks

  • Bob Barrows [MVP]

    #2
    Re: restrict access to page based on querystring value

    GTN170777 wrote:
    Hi Brynn,
    >
    Thanks for the link, useful site,..
    >
    I have tried playing with the code a little and had put the following
    together --
    >
    <%
    If Request.QuerySt ring("ACC") NOT LIKE '%User%' Then
    vbscript <sql

    You have the option of using regex or Instr. Here is how it would look
    with Instr:
    dim acc
    acc = Request.QuerySt ring("ACC")
    if Instr(acc, "User") 0 then

    Don't forget, Instr is case-sensitive. If you don't want case to be a
    factor:
    if Instr(lcase(acc ), "user") 0 then


    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Comment

    • =?Utf-8?B?R1ROMTcwNzc3?=

      #3
      Re: restrict access to page based on querystring value

      Spot on again Bob, thanks

      "Bob Barrows [MVP]" wrote:
      GTN170777 wrote:
      Hi Brynn,

      Thanks for the link, useful site,..

      I have tried playing with the code a little and had put the following
      together --

      <%
      If Request.QuerySt ring("ACC") NOT LIKE '%User%' Then
      vbscript <sql
      >
      You have the option of using regex or Instr. Here is how it would look
      with Instr:
      dim acc
      acc = Request.QuerySt ring("ACC")
      if Instr(acc, "User") 0 then
      >
      Don't forget, Instr is case-sensitive. If you don't want case to be a
      factor:
      if Instr(lcase(acc ), "user") 0 then
      >
      >
      --
      Microsoft MVP -- ASP/ASP.NET
      Please reply to the newsgroup. The email account listed in my From
      header is my spam trap, so I don't check it very often. You will get a
      quicker response by posting to the newsgroup.
      >
      >
      >

      Comment

      • Evertjan.

        #4
        Re: restrict access to page based on querystring value

        =?Utf-8?B?R1ROMTcwNzc 3?= wrote on 25 feb 2008 in
        microsoft.publi c.inetserver.as p.general:
        <%
        If Request.QuerySt ring("ACC") NOT LIKE '%User%' Then
        VBS does not understand apostrophed strings as litteral strings.

        So this line will show an compilation error.


        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        Working...