0

I need to develop a role based control access system in my application

In my case I have

  • aspx page
  • XML file
  • Custom role provider

each control in the aspx page should have an extra behavior to be enable or not depend on the user role

so when the page is loaded the control that will be available to user are only the controls that each enable state meet the user role

The As Is state on my project that I develop in each page a function that check each control roles and user roles if muchs the control will be enable if not it will be disabled

I don't like this check even when I try to have a base class that all my pages inherited from and it manage this but also the same if-else techniq!!

So my should be is to find a solution to put a control in the page easy then I have some class that read XML file which I have and it contain controls IDs for each page with it's Role and those class handle the controls availability depend on each control rols that come from the XML file !

The page directly renderd with controls as it should be available or not for the current authonticated user

AshOoO
  • 1,108
  • 3
  • 13
  • 34
  • So you do not want to use the IsInRole method that is built in? Maybe review and reword your last sentence as I do not understand what you are asking for. – Chad May 10 '11 at 15:44
  • @Chad I need to render my page after it pass a custome Role Manager[class to manage and XML file that hold roles for each control] So I don't need to get in each control in each page and perform a (if .. else) !! I just have a cantrol name then set the roles for it in XML file and my custom class will manage linking between page and controls which chould be enable or disable .... this my view now but if there's any idea that's what I'm asking for – AshOoO May 11 '11 at 06:03
  • @AshOoO - I'd suggest putting a (brief!) worked example of what you mean into your question, via the "edit" link underneath it, as it might help us put together an answer for your question! =) – Rob May 11 '11 at 09:46
  • @Rob I try to make it more clear, Thank u – AshOoO May 11 '11 at 11:32
  • I am sorry but i dont know of any addons with the built in functionality you are looking for. If you were to make one you are just going to do the things in the back end that you do not want to do in the code. ASP.Net is not designed with the type of functionality you are requesting in mind. You could always extend the control types you wish to implement but in order to check on the role you are probably still going to need to either call the IsInRole method or some hack that does the same thing differently. – Chad May 11 '11 at 13:00
  • @Chad >> Thanks alot but exactelly I don't want ASP to manage but I want to Checking for Access Rights in the presentation layer so when the page loaded it load with the only controls that could be used by the authonticated current user and need this with generic class or solution not if else statements in each page load all over the system just only management class for that – AshOoO May 14 '11 at 08:44
  • If you set visible to false in the code behind then the control will not be loaded. I usually set my control visiblilty based on role in the page load function. If there are alot of variablilty then i create a method to handle them all in one place. – Chad May 16 '11 at 14:59

0 Answers0