views:

118

answers:

2

0 vote down check

I'm thinking on creating standard users, roles, permissions table schema, add contorls table and permission would be 'for a role on a control' and then in form loading event fire up a method to set Enabled proprerty of controls due to user's role's permissions. Is this good idea or i should took a hammer and get this out of my head (and if i should, please tell me why ;) )

A: 

I probably would advise against the individual control roles table and just deal with setting the states of the controls in the application based on what Role the user has.

e.g.

Button adminButton = new Button();
Button userButton = new Button();
...

public void Form_Load(object sender, EventArgs e)
{
    User user = // find user
    adminButton.Enabled = (user.Role == UserRoles.Admin)
    userButton.Enabled = (user.Role == UserRoles.Admin || user.Role == UserRoles.Standard)
}

Other than that, it seems a normal approach.

James
i can't hardcode this like you suggest, becouse permissions have to be managable (i should be able to change through user firendly interface)
Adrian
If every control you have MUST be configurable i.e. unable to group them, then using a control table would be perfectly fine.
James
A: 

I've created a similar schema, works out reasonably well. Allows for fine-grained control; but it's also a lot of work to get all permissions right.

ammoQ