开发者

Add Group Membership to Custom Membership/Roles provider

Being fairly new to the MVC Framework, I am trying to establish a custom Membership provider which can suppor开发者_JAVA技巧t 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜