Print Page | Close Window

Roles not populated on client.

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3110
Printed Date: 23-Jan-2026 at 7:55pm


Topic: Roles not populated on client.
Posted By: gregweb
Subject: Roles not populated on client.
Date Posted: 24-Nov-2011 at 6:10am
On the client, I am trying to determine if a user is in a particular role.

In web.config, <roleManager enabled="true" />.

The ASPNet.db has a role created and a user is assigned the role.

If I open up ASPNet Configuration in Visual Studio, it shows the user, the role, and the user being in the role. So it is set up correctly.

I then log in as that user.

In the LoggedIn event, I check to see if the user is in a role:

bool isInRole = AuthenticationManager.Current.User.IsInRole("EmailAdmin");

However, this always returns false. In looking at User.Roles, it is always empty. However, it does show the correct user.

Any idea what's up?

Greg



Replies:
Posted By: DenisK
Date Posted: 29-Nov-2011 at 6:32pm
Hi Greg;

Are you using the UserBase class (DevForce's Default IPrincipal implementation)? This class will serialize the roles back to the client.

If you have a custom IPrincipal implementation instead, you need to make sure that the roles are serialized as part of the data contract.


Posted By: gregweb
Date Posted: 30-Nov-2011 at 5:06am
OK thanks, this is working now.



Print Page | Close Window