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.0Changing a userChanging a user's role while they are logged in
Previous
 
Next
New Post
3/22/2006 4:55 PM
 
When a user registers on my portal, they are initially setup in a "Free Trial" role.  One of the few pages that the Trial role has access to is a Purchase Account screen.  From this screen the user may purchase one of several account types (Personal, Academic, Corporate).  I have a role setup that corresponds to each of these account types, and these roles have permissions to other pages such as a Receipts page, which the Trial role cannot access.

On click of the submit button on the Purchase Account screen I am removing the user from the Trial role using the DotNetNuke.Security.Roles.RoleController.DeleteUserRole() function, and adding the user to their new role (which has access to the Receipts module) using the Security.Roles.RoleController.AddUserRole() function.  I am then redirecting the user to the Receipts page by doing:
Dim tabs As New Entities.Tabs.TabController
Response.Redirect(NavigateURL(tabs.GetTabByName("My Receipts", PortalId).TabID))

Both the aspnet_UsersInRoles and the UserRoles table seem to update correctly. However, when the Receipts page is loaded it says that I don't have access to that page.  I have found though, that if I wait for about a minute and then refresh, the page loads up fine.  Takes a minute though; before that time refreshing gives the same error message.

Does it cache the user's role and only periodically update it?  How can I force it to update this information so that the Receipts page will see the newly added role when I redirect to it?  Any help would be greatly appreciated.
 
New Post
3/24/2006 9:58 AM
 
Anyone have any experience with this?  I have still not been able to find any information as to why this happens or how to get around it.
 
New Post
3/24/2006 10:07 AM
 

here is the code (C#) that I use to reset the user's roles before i redirect them.  this seems to work pretty good.  I horked and converted it from the membership provider (if i remember right).

DataCache.ClearPortalCache(PortalId, true);

//This roles cookie stuff enables the features of a subscription right away.

//Rewrite the roles cookie...

string[] arrPortalRoles = rc.GetPortalRolesByUser(ActiveUserId, PortalSettings.PortalId);

// create a string to persist the roles

string strPortalRoles = string.Join(";",arrPortalRoles);

//create a cookie authentication ticket ( version, user name, issue time, expires every hour, don't persist cookie, roles )

System.Web.Security.FormsAuthenticationTicket RolesTicket =

new System.Web.Security.FormsAuthenticationTicket(1, objUserInfo.Username, DateTime.Now, DateTime.Now.AddHours(1), false, strPortalRoles);

// encrypt the ticket

string strRoles = System.Web.Security.FormsAuthentication.Encrypt(RolesTicket);

// send roles cookie to client

Response.Cookies["portalroles"].Value = strRoles;

Response.Cookies["portalroles"].Path = "/";

Response.Cookies["portalroles"].Expires = DateTime.Now.AddMinutes(1);


Jeff Martin
MCSD C#
 
New Post
3/24/2006 11:06 AM
 
Jeff,

That code is exactly what I was looking for.  It works perfectly!  Thank you for your help.

James Ausenbaugh
Software Developer
DevSource, LLC

P.S. - I took a look at the Homefree website, and it is really nice.  Looks like something I could probably use.  I'm gonna have another look around a little later - when I'm not working :)
 
New Post
3/27/2006 1:23 PM
 

Glad I could help.

 


Jeff Martin
MCSD C#
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Changing a userChanging a user's role while they are logged in


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