I have a table containing the administrators of my site. Each of these
administrators have access to different parts of the administration site.
For example, Lucy might have access to News.aspx and Customers.aspx while
Mike might have access only to Reports.aspx.
I planned to solve this by making creating roles with the same names as the
aspx-pages. Then I could just run some code in Application_BeginRequest:
'Lets say the user is requesting Customers.aspx and we have a role called
Customers
cm = <filename of requested page minus ".aspx">
If not User.IsInRole(cm) then response.redirect "start.aspx"
However, I do not know how to assign the appropriate roles to each user. How
do I solve this? Or is there another way to do it?
Thanks!
You need to add the users to a group in the Computer Management applet -
Systems Tools > Local Users and Groups >Groups.
Ken
"John Knoop" <joh...@home.se> wrote in message
news:udhqIfRO...@TK2MSFTNGP12.phx.gbl...
/john
"Ken Cox [Microsoft MVP]" <BANSPAM...@sympatico.ca> wrote in message
news:#2XKDjSO...@TK2MSFTNGP11.phx.gbl...
"John Knoop" <joh...@home.se> wrote in message
news:%23n7uYMT...@TK2MSFTNGP10.phx.gbl...
If you are using Windows Authentication, the roles map
onto user groups as Ken discussed.
If you are using Forms authentication, you can add roles
using a custom principal, ie :
In the global.asax Application_AuthenticateRequest
handler, you can get the logged in users roles from the
database into a array of strings, then assign them to the
new principal:
Context.User = new GenericPrincipal(Context.User.Identity,
roles);
Look at the IBS Portal app for an example
http://www.asp.net/IBS_Portal/DesktopDefault.aspx
In particular look at the AuthenticateRequest event
handlers at:
(VB.NET)
http://www.asp.net/IBS_Portal/vbdocs/sourceviewer/srcview.a
spx?path=globalasax.src&file=Global.asax&rows=2
(C#)
http://www.asp.net/IBS_Portal/sourceviewer/srcview.aspx?
path=globalasax.src&file=Global.asax&rows=2
(Watch for word wrap, etc)
Merak
What is the difference between Context.User and just User? When I try to set
User = new GenericPrincipal(User.Identity, roles) I get a read only-error.
Context.User seems to only apply within the realms of the current page. It
would be great if I could just set the User to this new GenericPrincipal
once (in the login page) and never again.
/john
"Chris Anderson (Merak)" <me...@vRbErMeOaVlEm.co.uk> wrote in message
news:07f201c33988$8e82ad10$a501...@phx.gbl...