Extending ASP.NET role providers

Posted by Quick Joe Smith on Stack Overflow See other posts from Stack Overflow or by Quick Joe Smith
Published on 2010-03-28T22:51:17Z Indexed on 2010/03/28 22:53 UTC
Read the original article Hit count: 406

Filed under:
|
|

Because the RoleProvider interface seems to treat roles as nothing more than simple strings, I'm wondering if there is any non-hacky way to apply an optional value for a role on a per-user basis.

Our current login management system implements roles as key-value pairs, where the value part is optional and usually used to clarify or limit the permissions granted by a role.

For example, a role 'editor' might contain a user 'barry', but for 'barry' it will have an optional value 'raptors', which the system would interpret to mean that Barry can only edit articles filed under the 'raptors' category.

I have seen elsewhere a suggestion to simply create additional delimited roles, such as 'editor.raptors' or somesuch. That's not really going to be ideal because it would bloat the number of roles greatly, and I can tell it's going to be a very hard sell to replace our current implementation (which is also very less than ideal, but has the advantage of being custom made to work with our user database).

I can tell already that the concatenation method mentioned above is going to involve a lot of tedious string-splitting and partial matching.

Is there a better way?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about roles