Reputation: 1021
I am trying to implement a custom role provider. We can implement the abstract class, RoleProvider
, which gives us access to override RoleProvider.IsUserInRole(Username, Rolename)
but we need to override the method from the Roles
class, Roles.IsUserInRole(Rolename)
but the class is sealed.
Is there any way possible to override this method to do a custom implementation of it?
Upvotes: 2
Views: 450
Reputation: 21477
I haven't touched custom role providers in nearly 8 years, but I know you can override the User object, and add custom properties on that by creating your own class that inherits from Page, and use that throughout your site. You can probably do the same for Roles as well.
Update
I just looked at my old code, and I don't think I ever figured out a way around it. We could add custom stuff to the Role, but not override some. It was fairly clumsy, so ultimately we went the route I mentioned above where we overrode the User object and it had all the methods on it that we wanted to use (User.IsInRole(string), User.IsInOneOfRoles(IEnumerable), User.AddToRole(string), User.HasPermission(string), etc. Sorry I couldn't be more help. I'll be watching to see if anyone else comes up with one.
Upvotes: 1