Asp.net membership / roles question asp.net
My application needs protection at different levels for different teams. For example, someone might be an admin for one team, but might just be a spectator for another.
Ideally, I would like to have one, small set of roles, but I would like to assign people to separate roles for each team. that is, "Joe" can be the TeamA administrator, but have access to the TeamB Reader.
Will the Asp.Net provider infrastructure be supported?
- Matt
Update. My problem is with the "IsInRole" method. It takes one parameter. Apart from hacking it (combining two elements together, like team id and role name), is there any other way to pull this off?
source to share
As far as I know, there are no groups for roles in terms of how the class works RoleProvider
, but no why you weren't able to implement the grouping structure in your data source. However, the RoleProvider supports different application names, so it might be possible to use this to come up with some way of segmenting the application into logical groups that are identified as different and therefore have different roles assigned to them.
EDIT:
In response to your edit, you can have the following structure in your database
Group Table Access Table Role Table
id | name id | name group_id | access_id | name
----------- ------------ ---------------------------
1 Team A 1 Guest 1 1 Team A Guest
2 Team B 2 User 1 2 Team A User
3 Admin 1 3 Team A Admin
a have a mechanism to update a field name
in a table Role
when a new row is inserted.
Implementing a custom RoleProvider is very simple. You just need to inherit from RoleProvider
and override the methods you need by writing the logic of where the RoleProvider should get the data from.
source to share
Not straight out of the box. You will need to create a custom provider to support this feature
here is an example of creating a custom membership provider http://www.asp.net/learn/videos/video-189.aspx
source to share