views:

224

answers:

1

Hi

Being fairly new to the MVC Framework, I am trying to establish a custom Membership provider which can support the concept of Groups or departments.

I need to assign each user to belong to one (and only one) of several groups - each group (and its members) can only view records which belong to it - identified by the GroupId.

I need to somehow store this groupid within the users profile so that when they are logged in and call (for example) the Index method on the controller, the groupid is passed which will then filter the records which the user can see.

I am sure it is a straightforward approach, but I seem to have a mental block with it.

Any insight will be helpful ( and probably embarassingly simple!)

Roger

+3  A: 

I wonder if you could use "roles" instead of "groups". Permissions can be handled easily with roles. Usually, a role is something like admin, manager, superuser, user, guest. But couldn't you use roles for your purposes?

Here's an explanation of using roles in the Membership provider: How To: Use Role Manager in ASP.NET 2.0. You can find lots more by searching for "roles" instead of "groups".

And in case you don't have the Membership source code as a reference, you can download it from this page Microsoft ASP.NET 2.0 Providers: Introduction to see how they code for roles in the basic version.

DOK
The problem I would have with setting up a role is the sheer potential number of roles.I have implemented a custom Membership provider and custom defined User table. Each user record has an additional GroupId associated with it. I can then filter the tables throughout the site with that GroupId. I also have roles layered on top to allow certain users to perform the varying functions (Add, delete etc.)Thanks for your input - that link was good background too.