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/30/2007 8:40 PM
 

Hey Gary,

Have you tried this on a live server - I tried a number of these combinations in the past - and many of them work fine on my dev system - but fail on live server environments with more agressing caching.

Cheers

Westa

 
New Post
4/2/2007 8:42 AM
 

Hey Westa,
  All of my systems have the same cacheing, "Moderate".  So there shouldn't be much of a difference and actually it worked better on my staging server (mirror of live) then it did on my dev server.

What are you using for you cache setting, maybe you need to decrease it?

Gary

 

 
New Post
4/2/2007 10:35 AM
 

Westa, I made some updates to the code that, actually, seems to make it work better.

I moved the call to the set permissions to the Page_Init

These are the steps that I used now, that seem to work real-time ever time
I can post the code if you would like, but here are just the steps for now

1. Clear the module permission cache for the tab
    DotNetNuke.Common.Utilities.DataCache.ClearModulePermissionsCache(this.TabID);

2. Get the current user info (UserController.GetCurrentUserInfo())

3. Call to set the roles by doing the following
     -U
sing the roles controller add and remove roles
     -R
etrieve the portal roles cookie value
     -Reset the portal roles cookie value to the new value.

4. Set the "Context" User info with the new roles

5. Update the user's account wiht the new roles (UserController.UpdateUser())

I had most of the code in the Page Load before, but now that I have moved it to the page init and added some more steps, it seems to be working better now

Before I did this update, the roles would get removed real-time, but there was still about a 10 sec delay on adding the roles and the modules/action buttons realizing that the user has the correct roles.

Let me know if you would like me to post some code snipets.

Gary

 
New Post
4/2/2007 10:53 AM
 

Actuallly  - Yeah - post the code if you could - will be handy for others as well

Westa

 
New Post
4/18/2007 10:38 AM
 

Hi Guys,

I tried Gary's solution but it didnt seem to work. An alternative that works for me is:

System.Web.HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies["portalroles"];

                    if (cookie != null)
                    {
                        if (cookie.Value.Trim().Length > 0)
                        {
                            //Retrieve the roles
                            FormsAuthenticationTicket roleTicket = FormsAuthentication.Decrypt(cookie.Value);
                          
                            //Set the roles
                            string cached_roles = roleTicket.UserData;

                            if (cached_roles != null)
                            {
                                cached_roles = cached_roles.Replace(oldRole, "");
                               
                                //Add the role name to the list
                                cached_roles = String.Concat(cached_roles, ";", roleInfo.RoleName);
                                cached_roles = cached_roles.Replace(";;", ";");

                               Response.Cookies["portalroles"].Value = FormsAuthentication.Encrypt(new FormsAuthenticationTicket(roleTicket.Version, roleTicket.Name, roleTicket.IssueDate, roleTicket.Expiration, roleTicket.IsPersistent, cached_roles));
                            }
                           
                        }

                    }

 

 
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