Search code examples
asp.netasp.net-membershipasp.net-roles

ASP.NET Membership/Roles - how to link user to multiple applications/roles?


I am working on a project to break-up a large web site into smaller, more specific sites. I need to be able to restrict access to these sites to only users that have the necessary permissions, and would like to make use of the existing membership/roles data model wherever possible.

So ideally, I would like to assign potentially multiple applications (as defined in the aspnet_applications table) and application specific roles (aspnet_roles) to a single user. However, the aspnet membership model does not seem to allow this, as the aspnet_users and aspnet_membership records hold a specific applicationID.

How would it be possible to assign a single user to multiple applications/roles?


Solution

  • If you don't want your data to be linked to one application perhaps in addition to the standard SqlMembership provider you could consider using a custom management/role provider.

    It has much more greater flexibility of data source usage, like , you could use your own tables in the database to store members/roles information and use those tables across multiple applications etc.

    You can even go further, for example you can implement the custom membership and role providers and create a separate module(assembly) and then reuse that module across your multiple applications.