Display logged in user name and restrict access based on User ID

Using Dreamwever (ASP VBScript) and Access.
I have a database containing leads that contractors will log into.  I have DW's authentication setup where I have a Contractors table containing usernames and passwords (and a field for the custom access level).
All leads have one contractor assigned to it.
Now I'd like to accomplish the following:
1. Be able to display the username of the contractor that is logged in.
2. Only show (filter) the leads for the logged-in contractor (I do not want Contractor A to see the leads of Contractor B).
What would I have to do to accomplish both objectives?
torysAsked:
Who is Participating?
 
bugs021997Commented:
1. Be able to display the username of the contractor that is logged in.
--> As you said you have DW's authentication setup against the CONTRACTORS TABLE where username/password is stored...now when you authenticate and allow access to the particular user you must have saving the CONTRACTOR DETAILS like username, firstname, lastname etc in some SESSIONS, COOKIES etc...if not then do that. Assuming that upon DW's authentication the username or say firstname/lastname is stored in a session we can show that as follows...

TO Display USERNAME : <%=Session("username")%>
OR
TO Display NAME : <%=Session("firstName") & " " & Session("lastName")%>




2. Only show (filter) the leads for the logged-in contractor (I do not want Contractor A to see the leads of Contractor B).
--> As you said leads are assigned to a particular contractor and you need to show only those leads which are based with the particular logged in CONTRACTOR for that you will need to modify your QUERY to the table which has got leads...

strSQL = "Select * from LEADS WHERE contractUserName='"&Session("username")&"'"




Modify your query as per the actual format.


Cheers
^_^
BUGS
0
 
torysAuthor Commented:
Can you show me how to define the session for the Contractor name in Dreamweaver?
0
 
fuzzboxerCommented:
You don't even need to create a session variable to display table information.  All you have to do in Dreamweaver is click on the Bindings tab in the Application panel.  You should see your recordset listed, so click on the plus sign and drag over the column you want to show.
0
 
torysAuthor Commented:
Regarding fuzzboxer's comment -- I'm not simply trying to output table info, I'm trying to diplay the name of the person who was just authenticated....there is more to just dragging a field name into the page.

I found a wonderful resource on how to store a session via DW (see http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16563&sliceId=2), however, I am still having difficulty storing the session -- normally I'd set the destionation page as the form action, but my login page shows the form action is a DW declared object (DW"s code that does all of the authenticating).
The login page contains two txt fields, "username" and "pass". On the destination page, I've set
<%session("sessContractor")=Request.Form("username")%>, but for whatever reason, the session is still not displaying that username on my destination page.
Any idea what I'm doing wrong?  
0
 
fuzzboxerCommented:
"I'm not simply trying to output table info"

Understood, but if you have setup your query properly, then it shouldn't matter.

"the session is still not displaying that username on my destination page."

How are you printing the session variable?  Try <%Response.Write(Session("sessContractor"))%>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.