protected override IEnumerable <KeyValuePair <string, string> > GetNonSelectedItems() { // Return here your unselected items. First value is the ID you will store into your field, the second one is the display text. var retVal = RolesInRolesManager.GetAllRoles().ToKeyValuePair(); return(retVal); }
public void Process(UnicornReserializeCompletePipelineArgs args) { var rolePredicate = args.Configuration.Resolve <IRolePredicate>(); // no predicate = configuration doesn't include any roles if (rolePredicate == null) { return; } var dataStore = args.Configuration.Resolve <IRoleDataStore>(); var logger = args.Configuration.Resolve <ILogger>(); logger.Info(string.Empty); logger.Info($"{args.Configuration.Name} roles are being reserialized."); dataStore.Clear(); var roles = RolesInRolesManager.GetAllRoles() .Select(role => new SitecoreRoleData(role)) .Where(role => rolePredicate.Includes(role).IsIncluded); int roleCount = 0; foreach (var role in roles) { dataStore.Save(role); roleCount++; } logger.Info($"{args.Configuration.Name} role reserialize complete. {roleCount} roles were reserialized."); logger.Info(string.Empty); }
protected override IEnumerable <KeyValuePair <string, string> > GetSelectedItems() { // Return here your selected items. First value is the ID you will store into your field, the second one is the display text. var selectedRoles = Value.Split('|'); var retVal = RolesInRolesManager.GetAllRoles().Where(rl => selectedRoles.Contains(rl.LocalName)).ToKeyValuePair(); return(retVal); }
private static IEnumerable <Role> GetRoles() { IEnumerable <Role> roles = RolesInRolesManager.GetAllRoles(); if (roles != null) { return(roles); } return(new List <Role>()); }
/// <summary> /// Pulls the selected Virtual User Roles from the InternalAccessItem /// </summary> /// <param></param> /// <returns></returns> public IEnumerable <Role> GetVirtualUserRoles() { var retVal = new List <Role>(); if (VirtualUserRoles != null && !VirtualUserRoles.IsNullOrEmpty()) { var selectedRoles = VirtualUserRoles.Split('|'); retVal = RolesInRolesManager.GetAllRoles().Where(rl => selectedRoles.Contains(rl.LocalName)).ToList(); } return(retVal); }
protected virtual void EvaluateOrphans(IRoleData[] roles) { var knownRoles = roles.ToLookup(key => key.RoleName); var allOrphanRoles = RolesInRolesManager.GetAllRoles(false) .Select(role => new SitecoreRoleData(role)) .Where(role => _rolePredicate.Includes(role).IsIncluded) .Where(role => !knownRoles.Contains(role.RoleName)) .ToArray(); foreach (var orphan in allOrphanRoles) { _loaderLogger.RemovedOrphanRole(orphan); System.Web.Security.Roles.DeleteRole(orphan.RoleName); } }
public void ShouldSwitchRolesInRolesProvider() { // arrange var roles = new[] { Role.FromName(@"sitecore/Editors") }; var localProvider = Substitute.For <RolesInRolesProvider, IThreadLocalProvider <RolesInRolesProvider> >(); localProvider.GetAllRoles(true).Returns(roles); // act using (new RolesInRolesSwitcher(localProvider)) { // assert RolesInRolesManager.GetAllRoles(true).Should().BeSameAs(roles); } RolesInRolesManager.GetAllRoles(true).Should().BeEmpty(); }
private static IEnumerable <string> GetValueList() { var roles = RolesInRolesManager.GetAllRoles(); return(roles.Select(r => r.Name).Append(Constants.AdminText).ToArray()); }