Discussion Locked

ASP permissions and href's from DB

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

My website is almost all ASP (not the public area), all of the pages are not cached and check for authorization from an ODBC DB I made in Access 2000, I need to know the code for including things in the database, such as the user's name, and if theyhave permission to go to a certain area, that link needs to be there, if they don't, it shouldn't show. The site started out as pages grouped by permissions granted, so with every new group that needs a specific type of page, a new set of pages needed to be made. I'm up to almost 1,000 pages today. and It's getting harder and harder to manage.
I don't understand web design like I probably should, and I don't understand Access like I probably should. If anyone knows how to tell me how to do this kindergardener style, it would make my life SO much easier. If any more details are needed, PLEASE feel free to email me, michael.roark@4its.org, or you can call toll-free 877-ITS-2095. Thanks in Advance.
Props go out to Don Q.

10 replies

by michael roark - ccna/da mcp 3csa

Tracking clients is not a problem, that issue has already been taken care of. Through Statistics and tracking javascript on every page. I just need to control which hyperlinks display, so I don't have 1,000 pages to take care of...

by peyison

Michael,

I'm not sure I'm totally clear on what you're looking for, but I'll take a shot and you can tell me if it's on the right track.

You want to control which links appear on a page based on the user.

One why to do this is to create conditional HTML based on the user. Something like:

<%
Select Case iUserGroup
Case 1
sLinks = "

This link is for UserGroup 1 only"

Case 2
sLinks = "

This link is for UserGroup 2"Case 3
sLinks = "

This is the first link for UserGroup 3
"
sLinks = sLinks & "This is the second link for UserGroup 3

End Select

%>

Then, in the body of your HTML, insert the text:

...

...

More links just for you:

<$ response.write sLinks %>

...

Let me know if this is on the right track.

by peyison

If you do this using ASP, it will not be visible by your users. The ASP code will create the HTML, and the users will only see the resulting HTML, not any of the code.

To determine the groups a user is in, you could have a Group field in a user table in your database. You table might look like:

UserId Text(15)
Password Text(15)
FirstName Text(50)
LastName Text(50)
UserGroup Number

Then you would have to have the user log in. It sounds like you're alrady using a database, so I'm not sure if this is the area you need help with. If so, let me know.
Once the user logs in, you can save the UserId and the Group in session variables:

Session("UserId") = sUserId
Session("UserGroup") = iUserGroup

You can then access these session variables on your other pages.

The first thing to do on each page is make sure the user is logged on:

'--if the session variable is empty, the user has not logged in yet
'--so redirect to the login page
If IsEmpty(Session("UserId")) Then
Response.Redirect "../authentication/login.asp"
Else
iUserGroup = Session("UserGroup")
End If

Now you can use iUserGroup in the select case statement.

by michael roark - ccna/da mcp 3csa

Yes, it could be controlled by groups, every individual is in the database, and has an individual log in, but it needs to be secured, to where you can't just look at the code to find out the hyperlink. That's why I was trying to do it from the DB, they can't see the database...
If you know a secure way to do it in groups, where the hyperlinks don't show in the HTML, please let me know...

by michael roark - ccna/da mcp 3csa

My Apologies, I didn't look at your example code very well, how do I tell the page which group they are in?
I'm sure I'll have to add an extra column or 15 onto the database to get this done, but it'll still be faster than going through over 1,000 pages...
can you walk me through it??

This discussion is closed to new replies.