General discussion

Locked

asp pulling username from login Database

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

This conversation is currently closed to new comments.

9 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

asp pulling username from login Database

Point value changed by question poster.

Collapse -

asp pulling username from login Database

by donq In reply to asp pulling username from ...

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!

Collapse -

asp pulling username from login Database

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,,

Collapse -

asp pulling username from login Database

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 <html> 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")="<servername>"
cn.Properties("Initial Catalog")="<dbname>"
cn.Properties("User ID") = "<user>"
cn.Properties("Password") = "<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%>
<a href = 'webpagefor1.asp'>Link 1 for 1</a> 'Add as many links as you need
<% else %> 'Add other if statements to check other levels if you need to. <a href = 'webpagefor2.asp'>Link 1 for 2</a>
<% 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.

Collapse -

asp pulling username from login Database

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

Collapse -

asp pulling username from login Database

by donq In reply to asp pulling username from ...

oNCE THE ANSWER IS REJECTED THE HELP STOPS - AS IT SHOULD!

Collapse -

asp pulling username from login Database

Poster rated this answer

Collapse -

asp pulling username from login Database

Don, I'm sorry, I didn't mean to give you a rejected, I was in a hurry to get some work done. Please tell me how to do this, and how many points you want...

Collapse -

asp pulling username from login Database

This question was closed by the author

Back to Web Development Forum
9 total posts (Page 1 of 1)  

Related Discussions

Related Forums