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.0Dynamically appling the roles to usersDynamically appling the roles to users
Previous
 
Next
New Post
3/29/2007 8:49 AM
 

Hello all,
I am running 4.4.1 

I created a new skin object that will add/remove roles to a user account upon entering certain pages within my portal.  The modules on the pages give edit rights to certain roles.

The roles are getting added and removed to the user accounts real-time just fine, but it takes about 30 secs for the modules to recognize that they user has them.  I know it has something to do with the cache...Is there any way to force some kind of clear of the roles/module cache so that the modules with see that the user has the correct roles real-time?

Any help would be greatly appreciated!
Thanks!

 
New Post
3/29/2007 11:51 AM
 

There are a number of issues with caching and dynamically altering roles.

- ive yet to find a solution to this same problem - short of modding the core code - or do a forced log off of the user and then having them re-log in.

I can make it work perfectly on my dev box all the time - but try putting the modules on a live production server and the roles changes dont get recognised.

The other issue is that while you can try flushing the caches and such - the roles() data is also being propagated into a clientside cookie - which means that until the user actually round trips the cookie thru a request cycle the old roles are still stuck in a weird kind of limbo.

The thing that Ive found most odd so far - is that the role deletes seems to occur instantly - but the role adds dont.

I too would be very interested in any responses you get to this one ...

Westa

 
New Post
3/29/2007 11:56 AM
 

Well, I have can get the roles to add and delete just fine...it is the modules on the page that are not recognizing that it has been done to that user.  The modules have the correct roles connected to them, but still there is a 30 sec delay.

I have tried a bunch of the "DataCache" utilities (ClearModulePermissionCache()...etc) but nothing works :-(

Ok, if I come up with anything I will let you know.

Thanks!

 
New Post
3/29/2007 6:09 PM
 
Westa, I think I got it...I am tweeking it a little...I will post back with the solution that I came up with.
 
New Post
3/30/2007 11:19 AM
 

Hey Westa,  I think I figured it out.  Had to go into the core dnn source code to find the answer, but it seems to be working pretty well.  You and another person I asked both mentioned that the cached user info only gets wiped out on logout...so that is where I went to find the code.

I hope one of the core developers sees this and corrects me if I am doing something that would hurt me down the line.

Otherwise...this is what I did:

//*** Add/Remove the roles normally with the roles controller ***

Here is what does updates the cached user info

string cached_roles = getCachedUserRoles();

//Set the new roles to the users cache
if (cached_roles != null)

    //Add the role name to the list
    cached_roles = String.Concat(cached_roles, ";", <<Name of the new role>>);

   //Updae the cached user info with the new list of roles
  ((
UserInfo)Context.Items["UserInfo"]).Roles = cached_roles.Split(';');
}

/// <summary>
/// Method to retrieve the cached roles from the cookie
/// </summary>
/// <returns></returns>
private static string getCachedUserRoles()
{

if (HttpContext.Current.Request.Cookies["portalroles"] != null)

{

// get roles from roles cookie
if (!HttpContext.Current.Request.Cookies["portalroles"].Value.Trim().Equals(""))

{

//Retrieve the roles
FormsAuthenticationTicket RoleTicket = FormsAuthentication.Decrypt(HttpContext.Current.Request.Cookies["portalroles"].Value);

//Set the roles
return RoleTicket.UserData;

}

}

return null;

}

The above will add a new role on the fly...Obviously if you want to remove the role, just call the same code, but instead of added to the list...remove the role name from the list.

Let me know if you have any questions or problems.

Hope this helps you out!
Gary

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Dynamically appling the roles to usersDynamically appling the roles to users


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