Re: Need help improving authorization

From: Chris Simmons (newsgroup.replies_at_netchris.com)
Date: 07/21/04


Date: Wed, 21 Jul 2004 17:09:06 -0400

On Wed, 21 Jul 2004 11:11:25 -0700, "AndiV" <andiv@yahoo.com> wrote:

>Each of my intranet page (windows authentication) needs to validate user's
>roles stored in the database. Currently, I retrieve the the
>User.Identity.Name property, then query the database for user's roles
>everytime a page is loaded, which is very inefficient.
>
>I think a more efficient approach would be to query the database only once
>for each user, the application_start event is probably the best place? Once
>this particular user's roles are retrieved, the roles can be concatenated as
>a delimied string and stored in cookie or a session variable. Then on each
>page load event, I just have to parse the roles string to apply
>authorization.
>
>I believe this scheme will work. But it seems more like a hack than a design
>pattern or a best practice. I'm seeking a .NET elegant solution. Please
>advise.
>
>TIA,
>Andi
>

I'd say go with your plan (except I hope you mean Session_Start, not
Application_Start).

I'd put your method to authenticate and authorize the user in some
public-accessible place so that you can use it from Session_Start
*and* your pages/controls if you need to re-query at some point during
the same session.

-- 
Thanks,
Chris Simmons


Relevant Pages

  • Re: Internet class differences...
    ... The database and web interface to the server is produced by a different ... Initially a WebClient class was used. ... This worked fine for submitting the query. ... retrieve the results but, instead, is sent to a login page from which it ...
    (microsoft.public.dotnet.general)
  • Re: Drilltrough Question
    ... not query the underlying relational database, ... that in AS2000 drilllthrough queries retrieved data from the underlying ... I could retrieve any column from any table in the ...
    (microsoft.public.sqlserver.olap)
  • Need help improving authorization
    ... Currently, I retrieve the the ... then query the database for user's roles ... I think a more efficient approach would be to query the database only once ... a delimied string and stored in cookie or a session variable. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How can I reduce the number of queries to my PostgreSQL database?
    ... SR> all books in the database, and all authors for each book. ... retrieve a list of all book_ids and book_titles. ... That's one query, if you're willing to make it advanced enough, ... although you need to make an aggregate to enable PostgreSQL to ...
    (comp.lang.python)
  • Re: Datetime within past week
    ... Prior to adding a new record to the database, I want to run a query to ... retrieve all of the records uploaded in the last 7 days. ...
    (comp.lang.php)