Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Roles questionRoles question
Previous
 
Next
New Post
10/9/2008 6:43 AM
 

Hi All,

 

I have a question about Roles. I have a module that allowes editting some data based on what role you are in. The reason is that we want the infromation (lets say a productlists) to be managed by several users. A productlist has roles attatched to it that allow editting.  Each role can consist of several users. We do not want to install the smae module 12 times if we have 12 different product lists. So we want the module to get the productlist by the role the user is in. So farn problem. However, affte diggin through the roleprovide code i find that because different role providers might be used (the module may go commercial) we can not easily just map our roleid field in the database to the roleid field in the (dotnetnuke) roles table because it could just as well be a different role table if the installation uses a different role provider. This also means that when we remove the role through the user managemnt we can not cascade this to ourshop. Ofcourse we could do a check everytime the module  is loaded if their are any roles "floating" and delete those but that should then be doen by using the dnn rolecontroller and looping through all roles in the code (can not be done in the databasse / sp because the sp does notknow which roleprovider is used).

Anmyone any idea how we can solve this?

 

Thanks in advance,

Alexander

 
New Post
10/9/2008 10:16 AM
 

Hi Alexander,

Your analysis is on target.  Because DNN could be configured to use any role provider, any backing store could (in theory) be used -- database, xml, webservice, and so on.  As such, you will not be able to create dependencies at the database level.  Your exclusive access point must be through the RoleProvider API, which is obviously a programmatic interface and not a data store.

The RoleInfo entity exposes a RoleId field, which you can safely use as a quasi-foreign key in your storage.  It seems that you are already on top of this.

As far as synchronization between roles and your database, you are pretty out of luck at the database level (triggers, cascading deletes, etc).  I suggest looking into deploying a scheduled task that performs this coordination; since it seems from your description that it would be okay for data to be unsynchronized in the very short term, a task that executed every hour, day, or whenever would likely yield a satisfactory solution.

Hope this gets you pointed in the right direction!

Brandon


Brandon Haynes
BrandonHaynes.org
 
New Post
10/9/2008 10:28 AM
 

Had one more idea that I thought I'd throw into the mix.

If it's very important to you to have guaranteed synchronization in your product data store, you might also consider developing your own role provider using a decorator pattern.  This provider would decorate another RoleProvider (usually DnnRoleProvider, and almost certainly configured at the web.config level).  Something like:

<add name="DecoratorRoleProvider" type="MyNamespace.DecoratorRoleProvider, MyAssembly" decoratedType="DotNetNuke.Security.Membership.DNNRoleProvider, DotNetNuke.Provider.DNNProvider" />

It may turn out best to move the decoratedType into its own web.config section, so that (in theory) other roleProviders could be chained on, but since one does not see this in practice, you're probably safe with the simple approach.

This provider would pass most all method calls to the decorated provider.  However, during certain calls (such as DeleteRole) the provider would execute its custom synchronization logic, and then pass control off as usual.

Such a setup would require a bit of web.config customization, but DNN offers some help there so that end-users would not have to tackle this.

Brandon


Brandon Haynes
BrandonHaynes.org
 
New Post
10/9/2008 4:04 PM
 

This really sounds great. You also gave me a good hint on another customer i'll probably have to create a new membership provider for. I'm not a fan of mingling around in the core, but making an entire new provider alse seems a lot of work. This could just do the trick as long as i keep an eye on core module changes..

As to the solution you offered in your first reply. Did that this afternoon.... :) I was actually planning on creating the schedule class tomorrow. To prevent errors i just did not make the field reference anything on DB level. Quick and dirty as they say.

Thanks a Lot

Alexander

 
New Post
8/25/2009 2:49 PM
 

Brandon,

I'm interested in using the decorator pattern to extend the role provider as you mentioned, do you have some shell example code along with the web.config settings? in VB.NET? For version 4.9 and higher.

I was reviewing your UPM Membership code samples in C# which are somewhat helpful, but I'm still a little unclear as to the syntax for creating the Decorator.

I am trying to determine if there is any value in creating the capability of a Role Hierarchy (IE RoleID, ParentRoleID satellite table)  that would allow admins to define Roles in such that if a user is a member of a role, they are also a member of all child roles.

Since many modules allow functional control via roles, including specific capabilities within the module, I thought it would be nice to simplify the administration in the specific case of hierarchy requirements.

Example / Setup:

Role 1 is a parent to role 1.1 and role 1.2 as defined in a satellite table(managed separately).

User 1 is ONLY a member of Role 1 and User 2 is ONLY a member of Role 1.2

So lets simply put 3 document modules on a page (D1, D1.1, and D1.2) each of which is viewable by their respective "Role" assignment with same Parent/Child Level defined under their individual module settings.

Required Result is the following :

User 1 sees all (3) modules on the page, and User 2 sees only the Module D1.2.

My thought is to simply Decorate the RoleProvider ... Get UserRole... functions to return "true" if the user is in the selected role or any "child" roles. Obviously, If the function returns a comma separated list of "Role Names", all child role names would be returned as well (known issues with string length on this)

Your Thoughts?

Chuck

 

 

 

 

 

 

 

 

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Roles questionRoles question


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out