New role not reflected in Thread.CurrentPrincipal.IsInRole

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
5/6/2011 8:51:18 AM
Gravatar
Total Posts 17

New role not reflected in Thread.CurrentPrincipal.IsInRole

Thank you for the software, I've just started using it. Looks very interesting, but I've just encountered my first problem. Maybe it's not a bug, still I think the fastest way to solve it will be to ask here.

I added new roles using the admin UI.

Then I log on to the portal using Client Application Services.

Then I check whether the logged on user is in a certain role.

It works for built-in roles, but not the newly added.

Why?

Greetings,

Maciek

 

 

5/6/2011 9:00:47 AM
Gravatar
Total Posts 17

Re: New role not reflected in Thread.CurrentPrincipal.IsInRole

I forgot to submit env info:

Win7

SQL

Version: 2-3-6-5

In previous post I wrote it may be not a bug, but it looks like it is, since the expected steps were performed and then it does not behave as expected (should include all defined roles).

Thanks,


 

Maciek

5/6/2011 1:32:34 PM
Gravatar
Total Posts 18439

Re: New role not reflected in Thread.CurrentPrincipal.IsInRole

Hi Maciek,

It should work as long as the user signed in after the role was created. If the user was already signed in he will need to sign out and sign in again to get a new role cookie.

Also it is possible that you are not checking for the correct role name if you renamed the role after creating it, it doesn't really change the underlying role name, it only changes the display name, as mentioned at the bottom of our Roles and Permissions document.

Hope that helps,

Joe

5/7/2011 4:46:29 AM
Gravatar
Total Posts 17

Re: New role not reflected in Thread.CurrentPrincipal.IsInRole

Thank you.

Indeed, when I add a new to role to a user who has not logged on at all yet, it works - the new roles are visible in IsInRole.

But once I log on as a certain user, it looks like the list of roles is remembered in its initial state and adding new roles is not reflected in IsInRole.

I log out using the code from Client Application Services walkthrough:

ClientFormsAuthenticationMembershipProvider authProvider =
                (ClientFormsAuthenticationMembershipProvider)
                System.Web.Security.Membership.Provider;
                authProvider.Logout();

and after that

Thread.CurrentPrincipal.Identity.IsAuthenticated correctly returns false.

But when I log on again, the newly added roles are not visible.

Is the list of roles cached somewhere?

Greetings,

Maciek

 

 

5/7/2011 7:37:15 AM
Gravatar
Total Posts 18439

Re: New role not reflected in Thread.CurrentPrincipal.IsInRole

Are you sure it is working for the standard roles included in mojoPortal?

Standard roles work the exact same way as custom roles so I don't see how one can work and the other not work.

The authentication service does not really pertain to roles, it only does authentication, there is a role service that can get user roles but it is separate from the authentication service.

Best,

Joe

 

5/7/2011 12:54:50 PM
Gravatar
Total Posts 17

Re: New role not reflected in Thread.CurrentPrincipal.IsInRole

Yes, it's not a matter of standard or non-standard roles, but caching roles during the first logon.

Both, adding and removing roles later does not affect the return from IsInRole.

So it looks that the roles are cached somewhere (even though ClientFormsAuthenticationMembershipProvider.Logout() is succesfully called)?

Thanks for your help,

Maciek

  

 

 

 

 

5/8/2011 3:03:27 AM
Gravatar
Total Posts 17

Re: New role not reflected in Thread.CurrentPrincipal.IsInRole

Hi,

I found the answer. This problem appears only in context of Client Application Services authentication (and not during portal use).

To get rid of of it I set the"Role service cache timeout" property in Client Application Services advanced settings  to 0.

Thank you for the portal software, I'd defenitely buy a beer, but not ready for online payments :-(, maybe when I'm in US later this year ;-).

Maciek

You must sign in to post in the forums. This thread is closed to new posts.