Setting Roles with Forms Authentication and Access 2003

Discussion in 'ASP .Net' started by =?Utf-8?B?RWQ=?=, Jun 4, 2004.

  1. Hi

    I currently have an asp.NET project. I'm using Access 2003 and forms authentication to authenticate users. Can anyone tell me how to set the roles in asp.NET so that it recognizes them? The logging in portion of my code works...What I need to know is how to allow access to certain pages to users with an administrator role while blocking access to regular users. My database has 3 columns, username, password, and roles. It is the last column that I would like asp.NET to recognize.

    Thank you

    Ed
     
    =?Utf-8?B?RWQ=?=, Jun 4, 2004
    #1
    1. Advertising

  2. While I am just starting with ASP.NET, I have used regular ASP so hopefully
    this still applies.

    In the authentication portion of your code, have it read the role of the
    user out of the database and store it in a Session Variable. On the pages
    you would like to restrict to Administrator only access, but a check to
    verify the user's role that is stored in the Session Variable at the very
    beginning of the page load. If the user isn't an Administrator, use the
    Redirect to send them into an invalid permissions page or whatever you want
    to setup. Finally depending on how your site is designed it would be good
    practice to not even show the links to visit the restricted page unless the
    Session Variable role is set to an Administator.


    "Ed" <> wrote in message
    news:...
    > Hi,
    >
    > I currently have an asp.NET project. I'm using Access 2003 and forms

    authentication to authenticate users. Can anyone tell me how to set the
    roles in asp.NET so that it recognizes them? The logging in portion of my
    code works...What I need to know is how to allow access to certain pages to
    users with an administrator role while blocking access to regular users. My
    database has 3 columns, username, password, and roles. It is the last
    column that I would like asp.NET to recognize.
    >
    > Thank you,
    >
    > Ed
     
    Paul Bobrowski, Jun 4, 2004
    #2
    1. Advertising

  3. "Ed" <> wrote in message
    news:...
    > Hi,
    >
    > I currently have an asp.NET project. I'm using Access 2003 and forms

    authentication to authenticate users. Can anyone tell me how to set the
    roles in asp.NET so that it recognizes them? The logging in portion of my
    code works...What I need to know is how to allow access to certain pages to
    users with an administrator role while blocking access to regular users. My
    database has 3 columns, username, password, and roles. It is the last
    column that I would like asp.NET to recognize.

    The standard way to do this is to get a list of roles out of your database,
    however you would do that. You will then save the list (perhaps as
    comma-separated values) in the UserData property of the Forms Authentication
    ticket. Then, in the AuthenticateRequest handler in global.asax, you'll pull
    the list out of UserData and supply it to the GenericPrincipal constructor.
    See HOW TO: Implement Role-Based Security with Forms-Based Authentication in
    Your ASP.NET Application by Using Visual Basic .NET
    (http://support.microsoft.com/default.aspx?scid=kb;en-us;306238) for an
    example.
    --
    John Saunders
    johnwsaundersiii at hotmail
     
    John Saunders, Jun 4, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    2
    Views:
    1,529
    Tommy
    Feb 13, 2004
  2. Phil Townsend

    forms authentication and roles

    Phil Townsend, Oct 27, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    439
    Phil Townsend
    Oct 27, 2004
  3. Phil Townsend

    forms authentication and roles

    Phil Townsend, Oct 29, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    330
    Phil Townsend
    Oct 29, 2004
  4. Eric
    Replies:
    2
    Views:
    596
  5. Eric
    Replies:
    0
    Views:
    205
Loading...

Share This Page