Reputation: 140
I am working in MVC3. I have created 3 roles: Administrator,Manager and Staff and have manager1 and manager2 in manager role. I want to give add,edit,view,delete privilege to manager. I don't want to give delete privilege to manager1. Can i override the rights of user over roles?If yes please tell me how to do it using membership class?Any good articles on providing privileges?
Upvotes: 2
Views: 118
Reputation: 81
Use the deny technique..
public class DenyAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
return !base.AuthorizeCore(httpContext);
}
}
use this like authorizeattribute only.
Upvotes: 1
Reputation: 141
first, membership providers doesn't provide any priveleges, they just stores account, profile, roles.
access to some actions you can give to roles and/or users, setting attibute [AuthorizeAttribute(Roles = "role1", Users = "manager2")]
on controllers and actions. so using these technic you can extend priveleges for manager2.
Upvotes: 0