Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Get users with certain group names sync problem


I have a query where I search for members in a specified range of group names. Works great but... If a user's roles change inside the "real" provider, the query doesn't seem to return the correct results until the user has logged in once more. Is there a job or something that exist that can force changes to be visible inside the data store that the query engine uses?

var cg1 = new CriteriaGroup();

membersQuery.Groups = new GroupCollectionCriterion();
membersQuery.Groups.Containing = new GroupCriterion();
membersQuery.Groups.Containing.Name = new StringCriterion();
membersQuery.Groups.Containing.Name.Includes = new StringInCriterion();
UserCollection members = QueryHandler.Instance.GetQueryResult<IUser, UserCollection>(membersQuery, ..


Feb 27, 2012 14:19

Have you tried to throw away cached results and then re-query once more?


Mar 19, 2012 15:00

I can't think that the roles synch will be involved when removing the cached result for any query? When I'm back working in that project I will give it a quick test run though... Thanks!

Mar 22, 2012 9:24

Hi Johan,
I had a similar problem once where I needed to update forum rights for a user, when the roles had changed inside the "real provider". I fixed it with the following code :

        /// <summary>
        /// Synchronize user roles/groups and invalidate cached entityitems for the user
        /// </summary>
        /// <param name="user">Cloned user object</param>
        /// <returns></returns>
        public static IUser SynchronizeUser(IUser user)
           string[] rolesForUser = Roles.GetRolesForUser(user.UserName);
            List<string> list1 = new List<string>(Enumerable.Where<string>((IEnumerable<string>)rolesForUser, (Func<string, bool>)(roleName => Integrator.ShouldTransferRole(roleName))));
            List<IGroup> list2 = new List<IGroup>();
            foreach (IGroup group in (CacheableCollectionBase<IGroup, GroupCollection>)user.Groups)
                if (!list1.Contains(group.Name) && Integrator.ShouldTransferRole(group.Name))
            foreach (IGroup group in list2)
            foreach (string roleName in list1)
            return user;

 I hope this helps 

Mar 26, 2012 10:05

I'd hoped something was built in but I can work with something like that! Thanks!

Mar 28, 2012 12:39
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.