World is now on Opti ID! Learn more
AI OnAI Off
World is now on Opti ID! Learn more
Have you tried to throw away cached results and then re-query once more?
QueryHandler.Instance.RemoveQueryResultCache(membersQuery);
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!
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)) list2.Add(group); else list1.Remove(group.Name); } foreach (IGroup group in list2) user.Groups.Remove(group); foreach (string roleName in list1) user.Groups.Add(Integrator.SynchronizeRole(roleName)); CommunitySystem.CurrentContext.DefaultSecurity.UpdateUser(user); return user; }
I hope this helps
I'd hoped something was built in but I can work with something like that! Thanks!
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?