ASP.NET Custom Role provider: Role depending on the context? -



ASP.NET Custom Role provider: Role depending on the context? -

i'm starting new project, , i've question custom role provider asp.net mvc 3.

i need have role verification several actions of constructor, said me, okay easy, can utilize role provider.

the problem role depending of current "context":

in fact users in database linked several "entities", , have role "a" entity x, , role b entity y. info displayed/edited "childrens" of entity

it's strictly separated: when log in, have take entity want work, , then, until inquire alter of entity, have info of entity , rights of entity.

the current "entity" stored in session.

the goal have no unauthorized menu/action entity x, because right allowed user y.

the problem in role provider, i've no way receive context, receive username.

so think do?(if can help, membership custom membership provider).

to block access specific pages implement rolemanagementfilter on actions. allow users in employee role, admin role access specific pages.

[requiresemployeerole(route = "account", action = "logon", order = 1)] public actionresult employeesettings(){ homecoming view(); }

what actionfilter based on role of user requesting page either redirect them route , action set route = "account", action = "logon" or allow them in.

below part of actionfilterattribute.

public override void onactionexecuting(actionexecutingcontext filtercontext) { string[] roles = roles.getrolesforuser(); string userrole = ""; if (roles.length > 0) userrole = roles[0]; if (regex.ismatch(userrole, role)) filtercontext.httpcontext.response.redirect(redirecturl(), true); }

i don't know how may entities have, , if feasable or not, if create roles each entity, attach users roles base of operations restrictions on actions if user in roles.getrolesforuser();

i found msdn article re action filters http://msdn.microsoft.com/en-us/magazine/gg232768.aspx might help. there plenty of examples out there hope helps out.

asp.net asp.net-mvc authorization membership-provider roleprovider

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -