473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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_authorizedUsers="1,2,3"
MM_authFailedURL="index.asp"
MM_grantAccess=false
If Session("MM_Username") <"" Then
If (false Or CStr(Session("MM_UserAuthorization"))="") Or _
(InStr(1,MM_authorizedUsers,Session("MM_UserAuthor ization"))>=1) Then
MM_grantAccess = true
End If
End If
If Not MM_grantAccess Then
MM_qsChar = "?"
If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
MM_referrer = Request.ServerVariables("URL")
if (Len(Request.QueryString()) 0) Then MM_referrer = MM_referrer & "?" &
Request.QueryString()
MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" &
Server.URLEncode(MM_referrer)
Response.Redirect(MM_authFailedURL)
End If
%>
It restricts access to the page based upon the following values –

MM_Username
MM_UserAuthorization

I believe that is checking to see whether MM_Username exists and if so
checking to see if the MM_UserAuthorization 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_authFailedURL (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_UserAuthorization it
checks to see whether the variable ACC (which is sent through
Request.QueryString) 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

Feb 23 '08 #1
3 3571
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.QueryString("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.QueryString("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.
Feb 25 '08 #2
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.QueryString("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.QueryString("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.
Feb 25 '08 #3
=?Utf-8?B?R1ROMTcwNzc3?= wrote on 25 feb 2008 in
microsoft.public.inetserver.asp.general:
<%
If Request.QueryString("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)
Feb 25 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Masterblue | last post by:
Hi, Right know im teaching myself a little about CDONTS . But know I want to sent data form a database with a form. I wou ld like to do the following: - I have made a page with set of records....
5
by: rathnesh | last post by:
when using a web application which includes taking an asp page then going to another asp page and coming back to first page ...some times connection to iis gets terminated and page canot be...
3
by: Paul | last post by:
Hi all, at present I I've built a website which can be updated by admin and users. My problem, I've combined "log in" and "access levels" to restrict access to certain pages, using the built...
28
by: gc | last post by:
Hi, What is the purpose of the restrict keyword? gc
7
by: tweak | last post by:
Can someone give me a short example as how to best use this keyword in your code? This is my understanding: by definition restrict sounds like it is suppose to restrict access to memory...
0
by: Matt Howeson | last post by:
Some time ago I posted a request for help with a problem I was having sometime ago whereby a 404 error would result if any access to the Querystring had been made before the Context.Rewritepath is...
4
by: fxs | last post by:
Hello, I've got the following elements on my page: A Body tag that looks like this: <body onload="setTabs()"> A Javascript script in the <head> that has: var foo; function setTabs() {...
1
by: Rico | last post by:
I have tried to access a database using asp.net. after some entries like 120+, I got an unspecified error message. Anyone know what is happening, it seems to be stuck at the same line even when i...
6
by: rainy6144 | last post by:
Does the following code have defined behavior? double *new_array(unsigned n) { double *p = malloc(n * sizeof(double)); unsigned i; for (i = 0; i < n; i++) p = 0.0; return p; }
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.