Click here to Skip to main content
15,909,530 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
We are trying to implement Role membership provider for securing our web application. We will be creating custom Role memebership provider as we already have our Ingres database containing all the required tables.
What we need to accomplish is along with Role we want another field let's say FacilityID to determine what all a logged on user can access in the application. How can we fit in this additional condition in Role membership model. Will a custom Profile provider be any help to us?
Any suggestion or related links would be helpful.
Posted

I had to do something similar a few years ago. We ended up implementing custom versions of MembershipProvider, MembershipUser and RoleProvider, all found in the System.Web.Security namespace.

Keep in mind that these are just classes. As with any inheritable class, your derived classes can add any method or property that you want. The constructor on our user class, for example, retrieves information about the user's roles and saves them as a list within the object; this allowed us to implement properties like HasAdministratorRole, which makes security checking very easy. We also implemented methods like LockUser and UnlockUser, which encapsulate calls to the membership provider to cancel or allow web access.

Exactly how you implement the new properties will depend a lot on your particular security model and needs, I can't really offer any advice on that. One book I found useful (still on my shelf although obviously out-dated) is "Pro ASP.NET 2.0 in VB 2005" by Laurence Moroney and Matthew MacDonald. That, and a lot of trial and error. X|

Good luck.
 
Share this answer
 
Thanks for the reply. Can you please elaborate on the role provider functionality you had implemented.

Gregory.Gadow: The entire class is 596 lines, which is a bit long to simply post. But basically....

We set up three tables in our Web database: WebUsers, WebRoles and WebUserRoles. Each user has a single entry in WebUsers. Each role has a single entry in WebRoles. WebUserRoles holds a list of what roles each user has; for example, I have three entries in that table, which allows me in the roles of Administrator, Publisher and FieldRep.

The class is written in VB.Net for the 2.0 framework and inherits from System.Web.RoleProvider. I overrode everything except the Description and Name properties to guarantee that I would have access to all the functionality I might need: the code access the web tables to do things like create and delete roles, add users to and remove them from roles, see if a given user has a given role, get a list of all roles that a given user has, and so on. Overriding the Initialize method allows me to put configuration info in the web.config file and read it out when an instance of the class is started.

Mind you, we set up our own web user management system, which allowed us to set up only what we needed and implement it exactly as we wanted. That greatly simplified my work, but it also meant we could not use Microsoft's web user management tools. If you want to use those tools, you will need to track down some scripts from Microsoft (I don't remember where they are, sorry) that you can run to set up your database to meet Microsoft's requirements.
 
Share this answer
 
v2
So essentially we have to add our own methods to be able to accomplish additional condition for fetching user's role per facility.

Also the application we are implementing will be a kind of centralized security application. So a user trying to access any application will first be redirected to this security application and on successful authentication will be redirected to respective app. So we have to do all the exception handling here so that there is no additional code required in the individual web apps. If you have any refrence kindly let me know.
Thanks again!
 
Share this answer
 
 
Share this answer
 
Comments
fjdiewornncalwe 19-Oct-11 13:52pm    
The question is a little old to be getting a new answer now. Please refrain from answering old questions like this in the future.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900