Discussion Locked

asp pulling username from login Database

0 helpful
9 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 areas) all of the page are not cached and check for authorization from an ODBC DB I made in Access, I just need to know the code for including things in the database, such as the user's name and if they have 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 permission 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 over 700 pages now... I need to figure out how to do this before my fingers fall off. If anyone else has a website that uses a database like this, or an SQL DB, and knows the code to do it, Please help...
Thanks,
Mike Roark

9 replies

by donq

Relax Michael,

You are lucky you're using Access! Your task just became very simple.

Create a text field to hold the user ID and set it's default value to:
"=CurrentUser()" leaving off the quotes.

Wherever this field appears the currentlyloggod in user ID will be pasted into the record "by default" and when the user moves on the value will be saved "by default".

Paste a similar field within each "Group" to see who logged in where! Each time a new user loggs in his/her ID replaces the last listing so if you need to save each log in it will be necassary to create a short procedure to append each CurrentUser value to a new Group log (Table) that you can read or delete as needed??

Your chore is an easy one - have fun and save those fingers for eating cookies!

by michael roark - ccna/da mcp 3csa

OK, I'm relaxed a little, where do I create the text field? another column in Access? and what is the code I need to put on the webpage?
You sound like you've done this plenty of times before, please help me get through this...
Thanks,,

by aking-robertson

I use an SQL DB, but the idea will be the same. I have a login page that allows the user to select his name in a
combo box (comes from db) & enter a password. On submit, goes to a new form & runs check to verify the password is correct, checks
security level. Certain links are then displayed based on security level. It's all done in an asp page using VBScript.
Here's some sample code: put all this before the tag: (This would be the page you submit the form to. )
dim cn, rs
set cn=server.CreateObject("ADODB.connection")
set rs=server.CreateObject ("ADODB.recordset")
cn.Provider="sqloledb"
cn.Properties("Data Source")=""
cn.Properties("Initial Catalog")=""
cn.Properties("User ID") = ""
cn.Properties("Password") = ""
cn.Open
%>
(put this in the body part of the page)
<%
dim varSecurityLevel, userid
userid = request.form("cboUser") 'Or whatever your form control is named.
rs.Open "Select securitylevel from table where userid = '" & userid & "'",cn
if not rs.EOF then
rs.MoveFirst
if securitylevel = 1 then%>
Link 1 for 1 'Add as many links as you need
<% else %> 'Add other if statements to check other levels if you need to. Link 1 for 2
<% end if%>
You can also do this all within one page by simply submitting the form to the same page.
I hope this helps you.

by michael roark - ccna/da mcp 3csa

I don't have the webserver on site, and I don't trust them with handling the SQL database, the mail servers down enough as it is.. If I get my own server on-site soon,, I will need your help though...
Thank you,
Michael Roark

This discussion is closed to new replies.