Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Paul de Quant 394 posts 1477 karma points
    Sep 13, 2017 @ 13:55
    Paul de Quant
    0

    Clearing Member Cache

    Hello,

    I'm programatically altering users member details, however the members cache is causing me all sorts of issues.

    Disabling the cache in umbracoSettings > UmbracoLibraryCacheDuration and setting to zero, but I don't necessarily want to disable this for everything.

    Is there a way to clear a particular members cache profile? So I can instantly see the updates I'm making? In particular I'm using Member Groups and assigning groups.

    Many thanks

    Paul

  • Marcio Goularte 356 posts 1248 karma points
    Sep 13, 2017 @ 14:43
    Marcio Goularte
    0

    This is a setting for content. Members are on Examine. You need to rebuild the index in the developer section

    https://our.umbraco.org/documentation/reference/config/umbracosettings/

    enter image description here

  • Paul de Quant 394 posts 1477 karma points
    Sep 13, 2017 @ 14:44
    Paul de Quant
    0

    Hey Marcio,

    Thanks for the response, can this be triggered programatically though?

    Thanks

    Paul

  • Marcio Goularte 356 posts 1248 karma points
    Sep 13, 2017 @ 14:50
  • Paul de Quant 394 posts 1477 karma points
    Sep 13, 2017 @ 14:52
    Paul de Quant
    0

    I clicked the rebuild but it didn't do anything.

    The issue I have is that I've deleted all the Member Groups from the system, yet when I run this:

    memberGroupService.GetByName(group)
    

    It always returns a value - even though the Database entries in UmrbacoNode are gone.

    I need to make sure these old entries are purged, but I don't know where to purge them from.

    Thanks

    Paul

  • Marcio Goularte 356 posts 1248 karma points
    Sep 13, 2017 @ 15:10
    Marcio Goularte
    0

    Got it. Member Groups are based on system.Web.Security.Membership as Roles.

    If you are not removing through the MemberGroupService, which is strange, try the RoleProvider.

    using System.Web.Security;
    Roles.DeleteRole("Group Name");
    

    https://24days.in/umbraco-cms/2015/extending-membership/

  • Paul de Quant 394 posts 1477 karma points
    Sep 13, 2017 @ 15:15
    Paul de Quant
    0

    Hi Marcio,

    That didnt work either.I just get this error:-

    'System.Array' does not contain a definition for 'DeleteRole' and no extension method 'DeleteRole' accepting a first argument of type 'System.Array' could be found (are you missing a using directive or an assembly reference?)

  • Marcio Goularte 356 posts 1248 karma points
    Sep 13, 2017 @ 15:17
    Marcio Goularte
    0

    How are you trying to remove it? show code please

  • Paul de Quant 394 posts 1477 karma points
    Sep 13, 2017 @ 15:22
    Paul de Quant
    0

    Ok, for the purpose of testing at the moment, I'm actually deleting them through the back office as you would do normally.

    So this code below, gets a list of groups from Active Directory, I check to see if they already exist in the system - if they don't I add them and if they do I assign them to the user I'm importing.

    It's the GetByName functions thats throwing me off, as after the group is deleted it still thinks there something there.

    foreach (string group in userGroups)
    {
       if (memberGroupService.GetByName(group) == null)
            {
                MemberGroup mg = new MemberGroup
                   {
                     Name = group,
                   };
    
                memberGroupService.Save(mg);
              }
    
              if (group == "Group 1" || group == "Group 2")
              {     memberService.AssignRole(newUserAccount.Id, group);
                 }
    
       }
    
         }
       }
    
  • Paul de Quant 394 posts 1477 karma points
    Sep 13, 2017 @ 15:28
    Paul de Quant
    0

    Ok, so here's the code I'm running with at the moment. I'm looping through a string list of groups from Active Directory, I then check to see if these groups exist in Umbraco. If they don't then create them, if they do then assign them to the user being imported. Teh problem we seem to have is that even with the database void of member groups the GetByName function still thinks there's something in there.

    foreach (string group in userGroups)
    { if (memberGroupService.GetByName(group) == null)
       {
          MemberGroup mg = new MemberGroup
          {
             Name = group,};
    
         memberGroupService.Save(mg);
      }
    
       if (group == "Group1" || group == "Group2")
       {  memberService.AssignRole(newUserAccount.Id, group);
           }
      }
    
  • Marcio Goularte 356 posts 1248 karma points
    Sep 13, 2017 @ 17:51
    Marcio Goularte
    0

    have you set up any Active Directory provider?

    UPDATE:

    var memberGroupService = ApplicationContext.Current.Services.MemberGroupService;

            foreach (string groupName in userGroups)
            {
                IMemberGroup group = memberGroupService.GetByName(groupName);
    
                if (group == null)
                {
                    MemberGroup mg = new MemberGroup
                    {
                        Name = groupName,
    
                    };
    
                    memberGroupService.Save(mg,raiseEvents: false);
                }
    
                if (groupName.Equals("Group1") || groupName.Equals("Group2"))
                {
                    memberGroupService.AssignRole(newUserAccount.Id, group);
                }
            }
    
  • Paul de Quant 394 posts 1477 karma points
    Sep 14, 2017 @ 06:51
    Paul de Quant
    0

    I haven't as such, I'm literally importing users into Umbraco rather than running off AD directly.

  • Marcio Goularte 356 posts 1248 karma points
    Sep 14, 2017 @ 11:50
  • Paul de Quant 394 posts 1477 karma points
    Sep 14, 2017 @ 12:16
    Paul de Quant
    0

    Hi again,

    I did consider this, but I need to be able to authenticate without be prompted to enter login details, which I don't think you can do with the Package you mentioned.

    Hope this makes sense,

    Thanks

    Paul

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies