473,795 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use array to limit access

I am trying to limit access to certain pages on our intranet, and have been
using the following code to do so,

dim Login, L, LL, StringLen, NTUser
Set Login = Request.ServerV ariables("LOGON _USER")
L=Len(Login)
LL=InStr(Login, "\")
StringLen=L-LL
NTUser = (Right(Login, StringLen))

If NTUser <"DLaing" Then
If NTUser <"DLowe" Then
If NTUser <"DWoods" Then
Response.Redire ct("http://swvtc06/swvtc/default.asp")
End If
End If
End If

The problem is that if I want to add more users to have access to the page,
then I have to add another IF and END IF line. I would like to implement
some way to do this using an array. For instance put the usernames into the
array and then if it matches then allow access, if not then redirect. I
know this is not a bulletproof way to do this, and there are more robust
methods, but this works very well for our user base and our needs. I am
having a really bad case of brain block, and cannot, for the life of me,
figure this out.

Thanks,
Drew
Mar 19 '08 #1
10 2479
"Drew" <dr********@swv tc.dmhmrsas.vir ginia.govwrote in message
news:OZ******** ******@TK2MSFTN GP05.phx.gbl...
I am trying to limit access to certain pages on our intranet, and have
been
using the following code to do so,

dim Login, L, LL, StringLen, NTUser
Set Login = Request.ServerV ariables("LOGON _USER")
L=Len(Login)
LL=InStr(Login, "\")
StringLen=L-LL
NTUser = (Right(Login, StringLen))

If NTUser <"DLaing" Then
If NTUser <"DLowe" Then
If NTUser <"DWoods" Then
Response.Redire ct("http://swvtc06/swvtc/default.asp")
End If
End If
End If

The problem is that if I want to add more users to have access to the
page,
then I have to add another IF and END IF line. I would like to implement
some way to do this using an array. For instance put the usernames into
the
array and then if it matches then allow access, if not then redirect. I
know this is not a bulletproof way to do this, and there are more robust
methods, but this works very well for our user base and our needs. I am
having a really bad case of brain block, and cannot, for the life of me,
figure this out.

First lets deal with that user name thing:-

Function GetUser()

sLogon = Request.ServerV ariables("LOGON _USER")

GetUser = Mid(sLogon, InStr(sLogon, "\"))

End Function

Note no Set when getting LOGON_USER and Mid third parameter is optional
which when missing means 'to the end of the string'.

Const gcsAllowedUser = "DLang; DLowe; DWood;"

If Instr(gcsAllowe dUsers, GetUser() & ";") = 0 Then
Response.Redire ct("http://swvtc06/swvtc/default.asp")
End If

If you want to restrict a set of pages then put the above code in an ASP
page of its own, say priviledged.asp in the root of your web then in each
page you want to protect:-

<!-- #include virtual="/priviledged.asp " -->
--
Anthony Jones - MVP ASP/ASP.NET
Mar 19 '08 #2
"Anthony Jones" <An*@yadayadaya da.comwrote in message
news:uV******** *****@TK2MSFTNG P06.phx.gbl...
"Drew" <dr********@swv tc.dmhmrsas.vir ginia.govwrote in message
news:OZ******** ******@TK2MSFTN GP05.phx.gbl...
>I am trying to limit access to certain pages on our intranet, and have
been
>using the following code to do so,

dim Login, L, LL, StringLen, NTUser
Set Login = Request.ServerV ariables("LOGON _USER")
L=Len(Login)
LL=InStr(Login , "\")
StringLen=L-LL
NTUser = (Right(Login, StringLen))

If NTUser <"DLaing" Then
If NTUser <"DLowe" Then
If NTUser <"DWoods" Then
Response.Redire ct("http://swvtc06/swvtc/default.asp")
End If
End If
End If

The problem is that if I want to add more users to have access to the
page,
>then I have to add another IF and END IF line. I would like to implement
some way to do this using an array. For instance put the usernames into
the
>array and then if it matches then allow access, if not then redirect. I
know this is not a bulletproof way to do this, and there are more robust
methods, but this works very well for our user base and our needs. I am
having a really bad case of brain block, and cannot, for the life of me,
figure this out.


First lets deal with that user name thing:-

Function GetUser()

sLogon = Request.ServerV ariables("LOGON _USER")

GetUser = Mid(sLogon, InStr(sLogon, "\"))

End Function

Note no Set when getting LOGON_USER and Mid third parameter is optional
which when missing means 'to the end of the string'.

Const gcsAllowedUser = "DLang; DLowe; DWood;"

If Instr(gcsAllowe dUsers, GetUser() & ";") = 0 Then
Response.Redire ct("http://swvtc06/swvtc/default.asp")
End If

If you want to restrict a set of pages then put the above code in an ASP
page of its own, say priviledged.asp in the root of your web then in each
page you want to protect:-

<!-- #include virtual="/priviledged.asp " -->
--
Anthony Jones - MVP ASP/ASP.NET
Thanks Anthony, that looks to work great... I don't use this on all pages,
just a few and this will work great!

Thanks,
Drew
Mar 19 '08 #3
I would store usernames in a database instead of an array in an ASP page
that you would have to maintain.

Jeff

"Drew" <dr********@swv tc.dmhmrsas.vir ginia.govwrote in message
news:OZ******** ******@TK2MSFTN GP05.phx.gbl...
>I am trying to limit access to certain pages on our intranet, and have been
using the following code to do so,

dim Login, L, LL, StringLen, NTUser
Set Login = Request.ServerV ariables("LOGON _USER")
L=Len(Login)
LL=InStr(Login, "\")
StringLen=L-LL
NTUser = (Right(Login, StringLen))

If NTUser <"DLaing" Then
If NTUser <"DLowe" Then
If NTUser <"DWoods" Then
Response.Redire ct("http://swvtc06/swvtc/default.asp")
End If
End If
End If

The problem is that if I want to add more users to have access to the
page, then I have to add another IF and END IF line. I would like to
implement some way to do this using an array. For instance put the
usernames into the array and then if it matches then allow access, if not
then redirect. I know this is not a bulletproof way to do this, and there
are more robust methods, but this works very well for our user base and
our needs. I am having a really bad case of brain block, and cannot, for
the life of me, figure this out.

Thanks,
Drew

Mar 19 '08 #4
"Jeff Dillon" <je********@hot mailremove.comw rote in message
news:ui******** ******@TK2MSFTN GP04.phx.gbl...
You could just use NT permissions too, at the IIS or File System level.

Create a local group on the server, and add the appropriate users to it.

Jeff
Very true, but as I said in an earlier message, setting permissions is
easier said than done... the hoops they make me jump through are terrible!

Drew
Mar 19 '08 #5
"Anthony Jones" <An*@yadayadaya da.comwrote:

>Where would you suggest the dictionary be stored??
Application object

--
Tim Slattery
MS MVP(Shell/User)
Sl********@bls. gov
http://members.cox.net/slatteryt
Mar 19 '08 #6
"Tim Slattery" <Sl********@bls .govwrote in message
news:ti******** *************** *********@4ax.c om...
"Anthony Jones" <An*@yadayadaya da.comwrote:

Where would you suggest the dictionary be stored??

Application object
The application object will not accept Single threaded objects such as the
dictionary object.

--
Anthony Jones - MVP ASP/ASP.NET
Mar 19 '08 #7
Anthony wrote on Wed, 19 Mar 2008 16:41:11 -0000:
"Drew" <dr********@swv tc.dmhmrsas.vir ginia.govwrote in message
news:OZ******** ******@TK2MSFTN GP05.phx.gbl...
>I am trying to limit access to certain pages on our intranet, and
have
been
>using the following code to do so,
>dim Login, L, LL, StringLen, NTUser
Set Login = Request.ServerV ariables("LOGON _USER")
L=Len(Login)
LL=InStr(Login , "\")
StringLen=L-LL
NTUser = (Right(Login, StringLen))
>If NTUser <"DLaing" Then
If NTUser <"DLowe" Then
If NTUser <"DWoods" Then
Response.Redire ct("http://swvtc06/swvtc/default.asp")
End If
End If
End If
>The problem is that if I want to add more users to have access to the
page,
>then I have to add another IF and END IF line. I would like to
implement some way to do this using an array. For instance put the
usernames into
the
>array and then if it matches then allow access, if not then redirect.
I know this is not a bulletproof way to do this, and there are more
robust methods, but this works very well for our user base and our
needs. I am having a really bad case of brain block, and cannot, for
the life of me, figure this out.

First lets deal with that user name thing:-
Function GetUser()
sLogon = Request.ServerV ariables("LOGON _USER")
GetUser = Mid(sLogon, InStr(sLogon, "\"))
End Function
Note no Set when getting LOGON_USER and Mid third parameter is optional
which when missing means 'to the end of the string'.
Const gcsAllowedUser = "DLang; DLowe; DWood;"
If Instr(gcsAllowe dUsers, GetUser() & ";") = 0 Then
Response.Redire ct("http://swvtc06/swvtc/default.asp")
End If
If you want to restrict a set of pages then put the above code in an ASP
page of its own, say priviledged.asp in the root of your web then in each
page you want to protect:-
If a username that is a substring of an allowed name, for example Lowe or
Wood, is added to the system, they'll be allowed access too without being
added to the gcsAllowedUser list ...

While it should work for a simple setup, I just wanted to point out a
possible pitfall of using this method on a wider scale.

--
Dan
Mar 20 '08 #8
Daniel Crichton wrote:
>
>Const gcsAllowedUser = "DLang; DLowe; DWood;"
>If Instr(gcsAllowe dUsers, GetUser() & ";") = 0 Then
Response.Redire ct("http://swvtc06/swvtc/default.asp")
End If
>If you want to restrict a set of pages then put the above code in an
ASP page of its own, say priviledged.asp in the root of your web
then in each page you want to protect:-

If a username that is a substring of an allowed name, for example
Lowe or Wood, is added to the system, they'll be allowed access too
without being added to the gcsAllowedUser list ...
This modification should remove that problem:

Const gcsAllowedUser = ";DLang;DLowe;D Wood;"
If Instr(gcsAllowe dUsers, ";" & GetUser() & ";") = 0 Then

Of course, if your network is allowing duplicate user ids, then you have
another problem.
If users from multiple domain names are possible (thus raising the
likelihood of duplicate user ids), then you need to stop removing the
domain from logon_user and include the domains in gcsAllowedUser:
Const gcsAllowedUser = ";dc1\DLang;dc1 \DLowe;dc2\DLow e;"


--
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.
Mar 20 '08 #9
So you don't have console access to the server?

Jeff
"Drew" <dr********@swv tc.dmhmrsas.vir ginia.govwrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
"Jeff Dillon" <je********@hot mailremove.comw rote in message
news:ui******** ******@TK2MSFTN GP04.phx.gbl...
>You could just use NT permissions too, at the IIS or File System level.

Create a local group on the server, and add the appropriate users to it.

Jeff

Very true, but as I said in an earlier message, setting permissions is
easier said than done... the hoops they make me jump through are terrible!

Drew

Mar 20 '08 #10

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

Similar topics

7
4729
by: Danny | last post by:
HI I am trying to do this: array4 = split(astring,chr(9)) and it seems the array4 cannot be larger than 256 how can I get around this? I am trying to read in a file and parse it line by line, but I cant just import as there are more than 256 fields, so i have to read it in with code.
6
12356
by: Hannu | last post by:
Hi. In the ldb file you can see the users of the mdb-file. If you open the mdb-file your machine and username will be written in the lbd- file. Allthough you close the mdb-file your name won't disappear from the ldb-file, before every user has closed the mdb-file. I have heard that there will be problems if the amount of users will be over 10 in mdb-files. Is that true? Hannu
12
7150
by: Eigenvector | last post by:
I've been dinking around with this code for a while now and I can't seem to figure out where the problem lies. The original problem was that I for some reason or another couldn't allocate few 80,000,000 element arrays. Normally that shouldn't be a problem but it was. So I tried to do some calloc calls and everything went south from there. Essentially I'm trying to read in a big file, stick each line into an array, then from then on do...
4
3966
by: MrBiggles | last post by:
Here's the sitch: I read in a csv file with 60000 lines (20 fields per record), and store the data to a local array. The file is read in and stored just fine and pretty quick. Now, if I try to assign that array to a session variable it chokes. e.g. create array and load each element with a row from the file (btw, each row is an array as well, using fgetcsv()). When local array is loaded, I assign to session var as so: $_SESSION =...
2
3451
by: xhunga | last post by:
I have try a new version of my work. I have put the sizes of the matrix into the matrix. A = number of rows A = number of columns The first element of the matrix is A instead of A. You can not use the row 0, and the column 0.
0
1329
by: josh.23.french | last post by:
Here's the code i have: $db = array(); //main array $db = array(); //table `main` $db = array('id'=>0, 'username'=>'joshfrench','userpass'=>'password','userlevel'=>'admin'); //row $db = array('id'=>1, 'username'=>'bob_smith','userpass'=>'psswrd','userlevel'=>'user'); //row
24
1966
by: Kavya | last post by:
int main (){ int a={{1,2,3},{4,5,6}}; int (*ptr)=a; /* This should be fine and give 3 as output*/ printf("%d\n",(*ptr)); ++ptr;
1
2267
by: assgar | last post by:
Hi I need help solving a porblem. I have a form that displays a checkbox, service code, description and dropdown with fees on each row. The fee_money and unit array only returns a selected value from the first item (checkbox).
13
1884
by: pereges | last post by:
Hi, can some one please tell me why this program is not able to function properly. I have a array a and i am trying to create a pointer array b which points to elements less than 40 in a. #include <stdio.h> #include <math.h> #include <stdlib.h> void create_ptr_list(int *a, int ***b, int n, int *size_ptr) {
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10002
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9044
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7543
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5565
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.