Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2007-09-30
6
Medium Priority
?
1,964 Views
Last Modified: 2008-12-31
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?
0
Comment
Question by:torys
  • 2
  • 2
5 Comments
 
LVL 14

Accepted Solution

by:
bugs021997 earned 672 total points
ID: 19988897
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
 

Author Comment

by:torys
ID: 19990346
Can you show me how to define the session for the Contractor name in Dreamweaver?
0
 
LVL 9

Assisted Solution

by:fuzzboxer
fuzzboxer earned 1344 total points
ID: 19990758
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
 

Author Comment

by:torys
ID: 19995656
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
 
LVL 9

Assisted Solution

by:fuzzboxer
fuzzboxer earned 1344 total points
ID: 19998256
"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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question