Is it possible using the Microsoft Role provider to "temporarily" add a user to a role at runtime?
I am implementing a custom Membership Provider and a custom Role Provider. It is working fine. I have a custom database that has all of my users and all of the roles and most of the associations between users and roles. There are a few roles where the code to figure out who is in the role is much more complicated. It sort of needs to be done on a user by user basis and there is no simple way to return a list of all of the users in one of these other roles. So what I am trying to do is add the user to the role at runtime. So when the user logs in I will get most of their roles from the custom Role Provider. However I want to run some additional code at login to check and see if they are also part of these other two roles. If they are then I want to add those two roles to the user sort of "temporarily" - for the session. In other words I want my application to know that they are part of those roles, but I don't want the provider to attempt to persist that back to the underlying database. I hope I have described t开发者_高级运维his correctly.
Am I even thinking about this correctly? Is this the right approach? Can this be done?
Please let me know if this is unclear or doesn't make sense.
Thanks, Corey
It sounds like you started coding before you completed and verified the design. I'd honestly advise you to start again and properly define your roles.
精彩评论