Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Role Based Security - DB Authentication

Status
Not open for further replies.

RealQuiet

Programmer
Feb 11, 2001
54
0
0
US
I am trying to limit access to certain areas of my site based on roles. I am not using Windows Authentication (not practical in this situation), and I'm running into some problems. I authenticate the login info against a database, retrieving associated roles for that user, and then creating a GenericPrincipal object with the FormsIdentity object and the list of roles. I then assign the GenericPrincipal object to Context.User. I did this based on some articles on Microsoft's site. I get no errors in my code, but I cannot get it to work properly. In my web.config file I am trying to limit access to a path by:

<location path=&quot;somepage.aspx&quot;>
<system.web>
<authorization>
<allow roles=&quot;Test&quot;/>
<deny users=&quot;*&quot;/>
</authorization>
</system.web>
</location>

This is denying requests for this page regardless of what I set for the roles in the GenericPrincipal object. Maybe I am way off base, but I would appreciate if someone pointed me in the right direction.
 
I think I have it worked out. Basically, you have create the GenericPrincipal Object and assign it to the context.user in the Application_AuthenticateRequest of the global.asax. This pulls the role information out of a cookie and assigns it for the current web request only. I had it in my login page, so it was just going away once that request was completed. Anyhow, here's a great article on the subject.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top