In my company we are developing a web application which contains many users,all these users will be having one or more role defined and for this roles we have separate setting page like this,
The Access checkbox on the left is checked if this role is able to see this menu when he logs in,as u can see the menu on the right,when u expand the menu node it shows the submenu under that menu,and we can set authorization if he can perform 'add,delete,edit,view and also hide submenu from menu'
and we have written a common class which checks the users role with this table and gives the result,on page load of every page we will call that class and apply the setting based on the result.
for ex: if user has logged in to a master page,we get the result on page load and apply the settings like this,
btnAdd.Enabled = result[0];
btnEdit.Enabled = result[1];
where result[0]
, result[1]
are the return value from the class.
Now my question is,is this the normal way of doing authorization in asp.net?(Not only for the page,but also for the controls in the page)
I am feel like doing sloppy coding like btn.Enabled = true
like this.
Since I have told what I need at the end,what will you all do for this?Just curious to know.
Questions:
1.What will be the drawbacks if I do authorization in this way?
2.What is the correct way of doing authorization in asp.net to meet my need (as explained above I need to enable,disable controls)
Thanks...