I'm working on a custom authentication handler in which I need to remove a user from all roles in Kentico, then re-add them to roles based on their roles in our external database.
Adding new roles from the database and adding a user to roles is no problem, but I'm having an issue removing the user from the roles they are currently assigned to.
//remove all user roles
foreach (DictionaryEntry roleName in user.SitesRoles["intranet"])
{
RoleInfo role = RoleInfoProvider.GetRoleInfo(roleName.Key.ToString(), CMSContext.CurrentSiteID);
UserInfoProvider.RemoveUserFromRole(user.UserID, role.RoleID);
}
It seems like this code should work, however the RemoveUserFromRole doesn't seem to actually remove the user from the role...any thoughts?
Thanks!