Click here to Skip to main content
15,900,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all
I am trying to create new roles using ASP.NET with vb code
and I know how to assign a user or group of users to a role.
but I want to know how can I set the role authorization at run time.
ex:
if I want to let the administrator to prevent some users to access some of pages, and allows them to access to other pages. how can I do that at run time?

Thank you
Posted

1 solution

There are several ways of achieving this. A common and relatively easy way is to have your users log into your website - that way you know the identity of the user. Save this in the system viewstate.

Create a function to check the user's permissions. Then on each page load, grab the userid of the logged in user (from the viewstate) and check which user group they belong to, and if that group has permission to view that page. These permissions could be stored in a database or similar.

Set different permissions for different groups of users, not against individual users.

Your question was general, so my answer was too. Hope it helps!
 
Share this answer
 
Comments
fadi77_net 7-Oct-10 5:24am    
Thank you Damian
but I dont want this way
I want to give them permissions by using roles at run time
ex:
if I want to create a role and name it "rlFoo"
and I want to give this role a permission to view page "CommingCalles.aspx" and prevent it to view page "Payments.aspx" at run time, is it possible to do that?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900