public virtual FilterCriteria GetExpiredGroupsFilter()
        {
            FilterCriteria filterCriterium = new FilterCriteria();

            filterCriterium.set_Child(new List <FilterCriteria>());
            FilterCriteria filterCriteria = filterCriterium;

            filterCriteria.set_Operator("and");
            FilterCriteria filterCriterium1 = new FilterCriteria();

            filterCriterium1.set_Attribute("IMGIsExpired");
            filterCriterium1.set_Operator("is exactly");
            filterCriterium1.set_Value("true");
            filterCriterium1.set_ValueType(5);
            filterCriteria.get_Child().Add(filterCriterium1);
            FilterCriteria filterCriterium2 = new FilterCriteria();

            filterCriterium2.set_Attribute("IMGIsDeleted");
            filterCriterium2.set_Operator("is exactly");
            filterCriterium2.set_Value("false");
            filterCriterium2.set_ValueType(5);
            filterCriteria.get_Child().Add(filterCriterium2);
            DateTime       date             = Utility.GetCurrentDate().Date;
            DateTime       deletionSpan     = date.AddDays((double)(Helper.AppConfiguration.get_DeletionDaysAfterExpiry() * -1));
            FilterCriteria filterCriterium3 = new FilterCriteria();

            filterCriterium3.set_Attribute("XGroupExpirationDate");
            filterCriterium3.set_Operator("less or equal");
            filterCriterium3.set_Value(deletionSpan.ToString("yyyy MMMM dd HH:mm:ss"));
            filterCriterium3.set_ValueType(4);
            filterCriteria.get_Child().Add(filterCriterium3);
            return(filterCriteria);
        }
        public virtual FilterCriteria GetExpiringGroupsFilter()
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            FilterCriteria filterCriterium = new FilterCriteria();

            filterCriterium.set_Child(new List <FilterCriteria>());
            FilterCriteria filterCriteria = filterCriterium;

            filterCriteria.set_Operator("and");
            FilterCriteria filterCriterium1 = new FilterCriteria();

            filterCriterium1.set_Attribute("IMGIsExpired");
            filterCriterium1.set_Operator("is exactly");
            filterCriterium1.set_Value("false");
            filterCriterium1.set_ValueType(5);
            filterCriteria.get_Child().Add(filterCriterium1);
            FilterCriteria filterCriterium2 = new FilterCriteria();

            filterCriterium2.set_Attribute("IMGIsDeleted");
            filterCriterium2.set_Operator("is exactly");
            filterCriterium2.set_Value("false");
            filterCriterium2.set_ValueType(5);
            filterCriteria.get_Child().Add(filterCriterium2);
            FilterCriteria filterCriterium3 = new FilterCriteria();

            filterCriterium3.set_Attribute("XGroupExpirationDate");
            filterCriterium3.set_Operator("less or equal");
            DateTime date = Utility.GetCurrentDate().Date;

            filterCriterium3.set_Value(date.ToString("yyyy MMMM dd HH:mm:ss"));
            filterCriterium3.set_ValueType(4);
            filterCriteria.get_Child().Add(filterCriterium3);
            return(filterCriteria);
        }
        public virtual FilterCriteria GetCriteriaForExpiringNotification()
        {
            FilterCriteria filterCriterium = new FilterCriteria();

            filterCriterium.set_Child(new List <FilterCriteria>());
            FilterCriteria filterCriteria = filterCriterium;

            filterCriteria.set_Operator("and");
            FilterCriteria filterCriterium1 = new FilterCriteria();

            filterCriterium1.set_Attribute("IMGIsExpired");
            filterCriterium1.set_Operator("is exactly");
            filterCriterium1.set_Value("false");
            filterCriterium1.set_ValueType(5);
            filterCriteria.get_Child().Add(filterCriterium1);
            FilterCriteria filterCriterium2 = new FilterCriteria();

            filterCriterium2.set_Attribute("IMGIsDeleted");
            filterCriterium2.set_Operator("is exactly");
            filterCriterium2.set_Value("false");
            filterCriterium2.set_ValueType(5);
            filterCriteria.get_Child().Add(filterCriterium2);
            FilterCriteria filterCriterium3 = new FilterCriteria();

            filterCriterium3.set_Attribute("XGroupExpirationDate");
            filterCriterium3.set_Operator("less or equal");
            DateTime date = DateTime.Now.AddDays(30);

            date = date.Date;
            filterCriterium3.set_Value(date.ToString("yyyy MMMM dd HH:mm:ss"));
            filterCriterium3.set_ValueType(4);
            filterCriteria.get_Child().Add(filterCriterium3);
            return(filterCriteria);
        }
        private FilterCriteria PrepareNestChildsCriteria(List <IdentityStoreObject> expiringGroups)
        {
            FilterCriteria filterCriterium = new FilterCriteria();

            filterCriterium.set_Child(new List <FilterCriteria>());
            FilterCriteria filterCriteria = filterCriterium;

            filterCriteria.set_Operator("or");
            foreach (IdentityStoreObject obj in expiringGroups)
            {
                FilterCriteria filterCriterium1 = new FilterCriteria();
                filterCriterium1.set_Attribute("IMSGObjectParentKey");
                filterCriterium1.set_Operator("is exactly");
                filterCriterium1.set_Value(obj.get_ObjectIdFromIdentityStore());
                filterCriterium1.set_ValueType(2);
                filterCriteria.get_Child().Add(filterCriterium1);
            }
            return(filterCriteria);
        }
        public virtual FilterCriteria GetEligibleGroupsFilter()
        {
            FilterCriteria filterCriterium = new FilterCriteria();

            filterCriterium.set_Child(new List <FilterCriteria>());
            FilterCriteria filterCriteria = filterCriterium;

            filterCriteria.set_Operator("and");
            FilterCriteria filterCriterium1 = new FilterCriteria();

            filterCriterium1.set_Attribute("IMGIsExpired");
            filterCriterium1.set_Operator("is exactly");
            filterCriterium1.set_Value("false");
            filterCriterium1.set_ValueType(5);
            filterCriteria.get_Child().Add(filterCriterium1);
            FilterCriteria filterCriterium2 = new FilterCriteria();

            filterCriterium2.set_Attribute("IMGIsDeleted");
            filterCriterium2.set_Operator("is exactly");
            filterCriterium2.set_Value("false");
            filterCriterium2.set_ValueType(5);
            filterCriteria.get_Child().Add(filterCriterium2);
            return(filterCriteria);
        }
        private List <IdentityStoreObject> GetOrphanGroups(List <string> attributesToLoad)
        {
            int totalFound = 0;
            List <IdentityStoreObject> owners = new List <IdentityStoreObject>();

            try
            {
                if (attributesToLoad == null)
                {
                    attributesToLoad = new List <string>();
                }
                if (!attributesToLoad.Contains("XAdditionalOwner"))
                {
                    attributesToLoad.Add("XAdditionalOwner");
                }
                if (!attributesToLoad.Contains(Helper.KnownProviderAttributes.get_DistinguishedName()))
                {
                    attributesToLoad.Add(Helper.KnownProviderAttributes.get_DistinguishedName());
                }
                if (!attributesToLoad.Contains(Helper.KnownProviderAttributes.get_Owner()))
                {
                    attributesToLoad.Add(Helper.KnownProviderAttributes.get_Owner());
                }
                FilterCriteria filterCriterium = new FilterCriteria();
                filterCriterium.set_Operator("and");
                filterCriterium.set_Child(new List <FilterCriteria>());
                FilterCriteria        filter           = filterCriterium;
                List <FilterCriteria> child            = filter.get_Child();
                FilterCriteria        filterCriterium1 = new FilterCriteria();
                filterCriterium1.set_Attribute(Helper.KnownProviderAttributes.get_Owner());
                filterCriterium1.set_Operator("not present");
                child.Add(filterCriterium1);
                FilterCriteria filterCriterium2 = new FilterCriteria();
                filterCriterium2.set_Operator("and");
                filterCriterium2.set_Child(new List <FilterCriteria>());
                FilterCriteria masterFilter = filterCriterium2;
                masterFilter.get_Child().Add(filter);
                List <FilterCriteria> filterCriterias  = masterFilter.get_Child();
                FilterCriteria        filterCriterium3 = new FilterCriteria();
                filterCriterium3.set_Attribute(Helper.KnownProviderAttributes.get_GroupType());
                filterCriterium3.set_Operator("is not");
                filterCriterium3.set_Value(Helper.KnownProviderAttributes.get_GroupTypeLocalSecurity_Builtin());
                filterCriterias.Add(filterCriterium3);
                FilterCriteria filterCriterium4 = new FilterCriteria();
                filterCriterium4.set_Operator("or");
                filterCriterium4.set_Child(new List <FilterCriteria>());
                FilterCriteria        childCriteria1   = filterCriterium4;
                List <FilterCriteria> child1           = childCriteria1.get_Child();
                FilterCriteria        filterCriterium5 = new FilterCriteria();
                filterCriterium5.set_Attribute(Helper.KnownProviderAttributes.get_IsCriticalSystemObject());
                filterCriterium5.set_Operator("is exactly");
                filterCriterium5.set_Value("FALSE");
                filterCriterium5.set_ValueType(5);
                child1.Add(filterCriterium5);
                List <FilterCriteria> filterCriterias1 = childCriteria1.get_Child();
                FilterCriteria        filterCriterium6 = new FilterCriteria();
                filterCriterium6.set_Attribute(Helper.KnownProviderAttributes.get_IsCriticalSystemObject());
                filterCriterium6.set_Operator("not present");
                filterCriterium6.set_Value(string.Empty);
                filterCriterium6.set_ValueType(5);
                filterCriterias1.Add(filterCriterium6);
                masterFilter.get_Child().Add(childCriteria1);
                FilterCriteria filterCriterium7 = new FilterCriteria();
                filterCriterium7.set_Operator("and");
                filterCriterium7.set_Child(new List <FilterCriteria>());
                FilterCriteria        extDataFilter    = filterCriterium7;
                List <FilterCriteria> child2           = extDataFilter.get_Child();
                FilterCriteria        filterCriterium8 = new FilterCriteria();
                filterCriterium8.set_Attribute("IMGIsExpired");
                filterCriterium8.set_Operator("is exactly");
                filterCriterium8.set_Value("false");
                filterCriterium8.set_ValueType(5);
                child2.Add(filterCriterium8);
                List <FilterCriteria> filterCriterias2 = extDataFilter.get_Child();
                FilterCriteria        filterCriterium9 = new FilterCriteria();
                filterCriterium9.set_Attribute("IMGIsDeleted");
                filterCriterium9.set_Operator("is exactly");
                filterCriterium9.set_Value("false");
                filterCriterium9.set_ValueType(5);
                filterCriterias2.Add(filterCriterium9);
                List <FilterCriteria> child3            = extDataFilter.get_Child();
                FilterCriteria        filterCriterium10 = new FilterCriteria();
                filterCriterium10.set_Attribute("XAdditionalOwner");
                filterCriterium10.set_Operator("present");
                child3.Add(filterCriterium10);
                SearchFilter sFilter = new SearchFilter(extDataFilter, masterFilter);
                sFilter.set_MergeCriteriaWithOrOperator(false);
                Dictionary <string, bool> containers = null;
                if ((Helper.CurrentTask.get_Targets() == null ? false : Helper.CurrentTask.get_Targets().Count > 0))
                {
                    containers = Helper.CurrentTask.get_Targets().ToDictionary <SchedulingTarget, string, bool>((SchedulingTarget target) => target.get_Target(), (SchedulingTarget target) => false);
                }
                ServicesSearchServiceClient searchServiceClient = new ServicesSearchServiceClient(false);
                owners = searchServiceClient.SearchEx(Helper.CurrentTask.get_IdentityStoreId(), 2, ref totalFound, sFilter, containers, string.Empty, 1, -1, 20000, attributesToLoad, false);
                owners = this.ExcludeSpecialGroups(owners);
            }
            catch (Exception exception)
            {
                Exception ex = exception;
                OrphanGroupProcessor.logger.Error(1022, 10294, ex.Message, ex, new object[0]);
            }
            return(owners);
        }