469,957 Members | 2,457 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,957 developers. It's quick & easy.

Setting Roles with Forms Authentication and Access 2003

Ed
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
Nov 18 '05 #1
2 1320
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" <an*******@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.com...
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

Nov 18 '05 #2
"Ed" <an*******@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.com...
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...b;en-us;306238) for an
example.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by VB Programmer | last post: by
3 posts views Thread by Sharat Koya | last post: by
5 posts views Thread by Andrew | last post: by
3 posts views Thread by charles | last post: by
4 posts views Thread by Ben | last post: by
2 posts views Thread by trullock | last post: by
1 post views Thread by scottw512 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.