Exemple #1
0
        public virtual IdentityStoreObject CloneObjectForUpdate(List <string> attributeNamesToClone, IdentityStoreObject objectToClone, IdentityStoreObject objectOrignal)
        {
            IdentityStoreObject identityStoreObject = new IdentityStoreObject();

            identityStoreObject.set_ObjectIdFromIdentityStore(objectToClone.get_ObjectIdFromIdentityStore());
            identityStoreObject.set_ObjectName(objectToClone.get_ObjectName());
            identityStoreObject.set_ObjectDisplayName(objectToClone.get_ObjectDisplayName());
            identityStoreObject.set_ObjectType(objectToClone.get_ObjectType());
            identityStoreObject.set_AttributesBusinessObject(new AttributeCollection());
            IdentityStoreObject newObject = identityStoreObject;

            foreach (string attributeName in attributeNamesToClone)
            {
                List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> values = this.GetAttributeValues(attributeName, objectToClone.get_AttributesBusinessObject());
                if ((values == null ? false : values.Any <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute>()))
                {
                    if (objectOrignal != null)
                    {
                        List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> origValues = this.GetAttributeValues(attributeName, objectOrignal.get_AttributesBusinessObject());
                        if ((origValues == null || origValues.Count != 1 ? false : StringUtility.EqualsIgnoreCase(origValues[0].get_Value(), values[0].get_Value())))
                        {
                            continue;
                        }
                    }
                    newObject.get_AttributesBusinessObject().Add(attributeName, values);
                }
            }
            return(newObject);
        }
        protected virtual bool HasReceivedNotificationInLast7Days(IdentityStoreObject group)
        {
            bool flag;

            if ((Helper.AppConfiguration.get_GenerateThirtyDaysToExpiryReport() || Helper.AppConfiguration.get_GenerateSevenDaysToExpiryReport() ? true : Helper.AppConfiguration.get_GenerateOnedayToExpiryReport()))
            {
                TimeSpan lastNotificationSpan = new TimeSpan();
                string   lastSentValue        = this.GetAttributeValue("IMGLastSentExpireNotificationDate", group.get_AttributesBusinessObject()).get_Value();
                if (!string.IsNullOrEmpty(lastSentValue))
                {
                    DateTime lastSentDate = Helper.ParseDateTime(lastSentValue);
                    if (lastSentDate.Date == DateTime.MinValue.Date)
                    {
                        GroupsProcessor.logger.ErrorFormat("HasReceivedNotificationInLast7Days: Invalid date format {0}", lastSentValue);
                        flag = false;
                        return(flag);
                    }
                    lastNotificationSpan = DateTime.Now.Subtract(lastSentDate);
                }
                flag = (lastNotificationSpan.Days <= 0 ? false : lastNotificationSpan.Days < 8);
            }
            else
            {
                flag = false;
            }
            return(flag);
        }
Exemple #3
0
        public virtual bool IsNotificationDueThirtyDays(IdentityStoreObject group, out int dueDays)
        {
            DateTime expirationDate;
            DateTime lastSentDate;
            TimeSpan span = new TimeSpan((long)0);

            if (DateTime.TryParse(this.GetAttributeValue("XGroupExpirationDate", group.get_AttributesBusinessObject()).get_Value() ?? string.Empty, out expirationDate))
            {
                span = expirationDate.Date.Subtract(DateTime.Now.Date);
            }
            dueDays = span.Days;
            bool notificationdue = false;

            if (span.Days == 30)
            {
                if (Helper.AppConfiguration.get_GenerateThirtyDaysToExpiryReport())
                {
                    notificationdue = true;
                }
            }
            if (notificationdue)
            {
                if (DateTime.TryParse(this.GetAttributeValue("IMGLastSentExpireNotificationDate", group.get_AttributesBusinessObject()).get_Value() ?? string.Empty, out lastSentDate))
                {
                    if (StringUtility.EqualsIgnoreCase(lastSentDate.Date.ToString(), DateTime.Now.Date.ToString()))
                    {
                        notificationdue = false;
                    }
                }
            }
            return(notificationdue);
        }
        public static List <IdentityStoreObject> PrepareCompressedData(List <IdentityStoreObject> list)
        {
            string cData = DataCompressionHelper.CompressObjects <List <IdentityStoreObject> >(list);
            List <IdentityStoreObject> compressedList = new List <IdentityStoreObject>();
            IdentityStoreObject        dummyGroup     = new IdentityStoreObject();

            AttributesHelper.SetAttributeValue("CompressedData", cData, dummyGroup.get_AttributesBusinessObject(), 3);
            compressedList.Add(dummyGroup);
            return(compressedList);
        }
 private static void RemoveExtraAttributes(IdentityStoreObject lGroup)
 {
     if (lGroup.get_AttributesBusinessObject().IsIn("IMSGManagedGroupType"))
     {
         lGroup.get_AttributesBusinessObject().Remove("IMSGManagedGroupType");
     }
     if (lGroup.get_AttributesBusinessObject().IsIn("IMSGIncludes"))
     {
         lGroup.get_AttributesBusinessObject().Remove("IMSGIncludes");
     }
     if (lGroup.get_AttributesBusinessObject().IsIn("IMSGExcludes"))
     {
         lGroup.get_AttributesBusinessObject().Remove("IMSGExcludes");
     }
 }
        private IdentityStoreObject GetParentGroup(List <IdentityStoreObject> expiringGroups, IdentityStoreObject group)
        {
            IdentityStoreObject parentGroup = null;
            string value = this.GetAttributeValue("IMSGObjectParentKey", group.get_AttributesBusinessObject()).get_Value() ?? string.Empty;

            if (!string.IsNullOrEmpty(value))
            {
                parentGroup = expiringGroups.FirstOrDefault <IdentityStoreObject>((IdentityStoreObject grp) => grp.get_ObjectIdFromIdentityStore().Equals(value, StringComparison.InvariantCultureIgnoreCase));
                if (parentGroup != null)
                {
                    parentGroup = this.GetParentGroup(expiringGroups, parentGroup) ?? parentGroup;
                }
            }
            return(parentGroup);
        }
Exemple #7
0
        public virtual bool ShouldExpireSecurityGroup(IdentityStoreObject group)
        {
            bool flag;

            if (!Helper.AppConfiguration.get_IsSecurityGroupExpirationEnabled())
            {
                Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute attribute = this.GetAttributeValue("groupType", group.get_AttributesBusinessObject());
                attribute.set_Value(attribute.get_Value() ?? string.Empty);
                flag = (attribute.get_Value() == "4" || attribute.get_Value() == "2" ? true : attribute.get_Value() == "8");
            }
            else
            {
                flag = true;
            }
            return(flag);
        }
        protected virtual bool PrepareGroupForLifeExtension(IdentityStoreObject grp)
        {
            bool flag;

            try
            {
                if (!Helper.AppConfiguration.get_IsGroupAttestationEnabled())
                {
                    TimeSpan lastNotificationSpan = new TimeSpan();
                    string   lastSentValue        = this.GetAttributeValue("IMGLastSentExpireNotificationDate", grp.get_AttributesBusinessObject()).get_Value();
                    if (!string.IsNullOrEmpty(lastSentValue))
                    {
                        DateTime lastSentDate = Helper.ParseDateTime(lastSentValue);
                        if (lastSentDate.Date == DateTime.MinValue.Date)
                        {
                            GroupsProcessor.logger.ErrorFormat("PrepareGroupForLifeExtension: Invalid date format {0}", lastSentValue);
                        }
                        lastNotificationSpan = DateTime.Now.Subtract(lastSentDate);
                    }
                    else if ((Helper.AppConfiguration.get_GenerateSevenDaysToExpiryReport() ? true : Helper.AppConfiguration.get_GenerateOnedayToExpiryReport()))
                    {
                        DateTime date = DateTime.Now.AddDays(7);
                        date = date.Date;
                        this.SetAttributeValue("XGroupExpirationDate", date.ToString("yyyy MMMM dd HH:mm:ss"), grp.get_AttributesBusinessObject());
                        flag = true;
                        return(flag);
                    }
                }
                else
                {
                    flag = false;
                    return(flag);
                }
            }
            catch (Exception exception)
            {
                Exception ex = exception;
                LogExtension.LogException(GroupsProcessor.logger, string.Format("An Error occured while performing GLM Expiry operation on group: {0} Reason: {1}", this.GetAttributeValue(Helper.KnownProviderAttributes.get_DisplayName(), grp.get_AttributesBusinessObject()).get_Value() ?? string.Empty, ex.Message), ex);
            }
            flag = false;
            return(flag);
        }
Exemple #9
0
 private Dictionary <string, Dictionary <string, IdentityStoreObject> > EnsureChildGroups(int identityStoreId, ServicesGroupServiceClient groupClient, Dictionary <string, Dictionary <string, IdentityStoreObject> > managedGroups)
 {
     foreach (KeyValuePair <string, Dictionary <string, IdentityStoreObject> > pair in managedGroups)
     {
         try
         {
             List <IdentityStoreObject> childGroups = groupClient.GetAllLevelCurrentChildGroups(identityStoreId, pair.Key, null, new List <string>()
             {
                 "IMSGManagedGroupType",
                 "IMSGObjectParentKey",
                 Helper.KnownProviderAttributes.get_DistinguishedName()
             });
             Dictionary <string, IdentityStoreObject> childDict = pair.Value;
             IdentityStoreObject[] array = childGroups.ToArray();
             for (int i = 0; i < (int)array.Length; i++)
             {
                 IdentityStoreObject g = array[i];
                 if (!childDict.ContainsKey(g.get_ObjectIdFromIdentityStore()))
                 {
                     childDict.Add(g.get_ObjectIdFromIdentityStore(), g);
                 }
             }
             ILookup <string, IdentityStoreObject>        childGroupsLookup = childGroups.ToLookup <IdentityStoreObject, string>((IdentityStoreObject c) => c.get_ObjectIdFromIdentityStore());
             KeyValuePair <string, IdentityStoreObject>[] keyValuePairArray = childDict.ToArray <KeyValuePair <string, IdentityStoreObject> >();
             for (int j = 0; j < (int)keyValuePairArray.Length; j++)
             {
                 KeyValuePair <string, IdentityStoreObject> childPair = keyValuePairArray[j];
                 if (!childGroupsLookup[childPair.Key].Any <IdentityStoreObject>())
                 {
                     childDict.Remove(childPair.Key);
                 }
             }
         }
         catch (Exception exception)
         {
             Exception ex = exception;
             this.logger.Error(string.Concat("Error occurred in getting child groups after smart group update. ", ex.Message));
             continue;
         }
     }
     return(managedGroups);
 }
        public static string GetAttributeValue(IdentityStoreObject directoryObject, string attrName)
        {
            string empty;

            if ((directoryObject == null ? true : directoryObject.get_AttributesBusinessObject().get_AttributesCollection().Count <= 0))
            {
                empty = string.Empty;
            }
            else if (!directoryObject.get_AttributesBusinessObject().get_AttributesCollection().ContainsKey(attrName))
            {
                empty = string.Empty;
            }
            else
            {
                KeyValuePair <string, List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> > keyValuePair = directoryObject.get_AttributesBusinessObject().get_AttributesCollection().FirstOrDefault <KeyValuePair <string, List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> > >((KeyValuePair <string, List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> > y) => StringUtility.EqualsIgnoreCase(y.Key, attrName));
                List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> attrObject = keyValuePair.Value;
                empty = ((attrObject == null ? true : attrObject.Count <= 0) ? string.Empty : attrObject.FirstOrDefault <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute>().get_Value());
            }
            return(empty);
        }
        public virtual string GetUpdatedDisplayName(IdentityStoreObject group)
        {
            Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute displayName = this.GetAttributeValue(Helper.KnownProviderAttributes.get_DisplayName(), group.get_AttributesBusinessObject());
            if (StringUtility.IsBlank(displayName.get_Value()))
            {
                displayName = this.GetAttributeValue(Helper.KnownProviderAttributes.get_Name(), group.get_AttributesBusinessObject());
            }
            displayName.set_Value(displayName.get_Value() ?? string.Empty);
            string updatedDisplayName = displayName.get_Value();

            if (updatedDisplayName.StartsWith("Expired_"))
            {
                updatedDisplayName = updatedDisplayName.Remove(0, "Expired_".Length);
            }
            if (!updatedDisplayName.StartsWith("Deleted_"))
            {
                updatedDisplayName = string.Concat("Deleted_", updatedDisplayName);
            }
            return(updatedDisplayName);
        }
Exemple #12
0
        public virtual bool IsSystemGroup(IdentityStoreObject group)
        {
            bool flag;

            if (group != null)
            {
                string groupDn = this.GetAttributeValue(Helper.KnownProviderAttributes.get_DistinguishedName(), group.get_AttributesBusinessObject()).get_Value() ?? string.Empty;
                if ((groupDn.IndexOf("OU=Microsoft Exchange Security Groups", StringComparison.InvariantCultureIgnoreCase) > -1 ? false : groupDn.IndexOf("CN=Microsoft Exchange System Objects", StringComparison.InvariantCultureIgnoreCase) <= -1))
                {
                    flag = (!groupDn.ToUpper().Contains("CN=BUILTIN") ? false : true);
                }
                else
                {
                    flag = true;
                }
            }
            else
            {
                flag = false;
            }
            return(flag);
        }
Exemple #13
0
        private Group ConvertToGroup(IdentityStoreObject identityStoreObject)
        {
            Group group1;

            if (!(identityStoreObject is Group))
            {
                Group group = new Group();
                group.set_ObjectIdFromIdentityStore(identityStoreObject.get_ObjectIdFromIdentityStore());
                group.set_ObjectName(identityStoreObject.get_ObjectName());
                group.set_ObjectDisplayName(identityStoreObject.get_ObjectDisplayName());
                group.set_DisplayName(identityStoreObject.get_ObjectDisplayName());
                group.set_ObjectType(identityStoreObject.get_ObjectType());
                group.set_AttributesBusinessObject(identityStoreObject.get_AttributesBusinessObject());
                group.set_StopNotification(identityStoreObject.get_StopNotification());
                group1 = group;
            }
            else
            {
                group1 = identityStoreObject as Group;
            }
            return(group1);
        }
Exemple #14
0
        public virtual bool ExtendGroupLife(int days, IdentityStoreObject group)
        {
            DateTime expirationDate;
            bool     flag;

            Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute expirationDateDto = this.GetAttributeValue("XGroupExpirationDate", group.get_AttributesBusinessObject());
            if (StringUtility.IsBlank(expirationDateDto.get_Value()))
            {
                flag = false;
            }
            else if (DateTime.TryParse(expirationDateDto.get_Value(), out expirationDate))
            {
                expirationDate = expirationDate.AddDays((double)days).Date;
                expirationDateDto.set_Value(expirationDate.ToString("yyyy MMMM dd HH:mm:ss"));
                flag = true;
            }
            else
            {
                flag = false;
            }
            return(flag);
        }
Exemple #15
0
        public virtual bool IsGroupInExcludedContainer(IdentityStoreObject group)
        {
            bool excludeGlmContainers;

            if (group != null)
            {
                string groupDn = this.GetAttributeValue(Helper.KnownProviderAttributes.get_DistinguishedName(), group.get_AttributesBusinessObject()).get_Value() ?? string.Empty;
                if (Helper.AppConfiguration.get_GlmContainers().Count != 0)
                {
                    string str = this.ExtractContainerName(groupDn);
                    excludeGlmContainers = (!Helper.AppConfiguration.get_ExcludeGlmContainers() ? !Helper.AppConfiguration.get_GlmContainers().Any <SelectedContainer>((SelectedContainer c) => StringUtility.EqualsIgnoreCase(c.get_Name(), str)) : Helper.AppConfiguration.get_GlmContainers().Any <SelectedContainer>((SelectedContainer c) => StringUtility.EqualsIgnoreCase(c.get_Name(), str)));
                }
                else
                {
                    excludeGlmContainers = !Helper.AppConfiguration.get_ExcludeGlmContainers();
                }
            }
            else
            {
                excludeGlmContainers = false;
            }
            return(excludeGlmContainers);
        }
Exemple #16
0
 public virtual bool IsGroup(IdentityStoreObject group)
 {
     //
     // Current member / type: System.Boolean Imanami.GroupID.TaskScheduler.Glm.GroupsProcessor::IsGroup(Imanami.GroupID.DataTransferObjects.DataContracts.Services.IdentityStoreObject)
     // File path: C:\Users\Administrator.ERISED\Desktop\Production\Imanami.GroupID.TaskScheduler.exe
     //
     // Product version: 2019.1.118.0
     // Exception in: System.Boolean IsGroup(Imanami.GroupID.DataTransferObjects.DataContracts.Services.IdentityStoreObject)
     //
     // Object reference not set to an instance of an object.
     //    at ž..•( ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RenameEnumValues.cs:line 77
     //    at †”.‰Ÿ.—š(ICodeNode ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 87
     //    at †”.‰Ÿ.Visit(ICodeNode ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 276
     //    at †”.‰Ÿ.Visit[„Ÿ,†Ÿ](„Ÿ ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 286
     //    at †”.‰Ÿ.Visit( ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 322
     //    at †”.‰Ÿ.•( ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 499
     //    at ž..•( ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RenameEnumValues.cs:line 68
     //    at †”.‰Ÿ.—š(ICodeNode ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 87
     //    at †”.‰Ÿ.Visit(ICodeNode ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 276
     //    at †”.‰Ÿ.•( ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 523
     //    at †”.‰Ÿ.—š(ICodeNode ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 95
     //    at †”.‰Ÿ.Visit(ICodeNode ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 276
     //    at †”.‰Ÿ.•(IfStatement ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 360
     //    at †”.‰Ÿ.—š(ICodeNode ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 55
     //    at †”.‰Ÿ.Visit(ICodeNode ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 276
     //    at †”.‰Ÿ.Visit[„Ÿ,†Ÿ](„Ÿ ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 286
     //    at †”.‰Ÿ.Visit(‰ ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 317
     //    at †”.‰Ÿ.”(•Ÿ ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Ast\BaseCodeTransformer.cs:line 337
     //    at ž..œ(DecompilationContext ™, •Ÿ Ÿ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Steps\RenameEnumValues.cs:line 48
     //    at ‚–.™“.(MethodBody €–, •Ÿ Ÿ, ILanguage ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:line 88
     //    at ‚–.™“.‹(MethodBody €–, ILanguage ) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\DecompilationPipeline.cs:line 70
     //    at Telerik.JustDecompiler.Decompiler.Extensions.›“(™“ œ“, ILanguage , MethodBody €–, DecompilationContext& ™) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:line 95
     //    at Telerik.JustDecompiler.Decompiler.Extensions.š“(MethodBody €–, ILanguage , DecompilationContext& ™,  œ–) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\Extensions.cs:line 58
     //    at ——.ƒ˜.—(ILanguage , MethodDefinition €,  œ–) in C:\DeveloperTooling_JD_Agent1\_work\15\s\OpenSource\Cecil.Decompiler\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 117
     //
     // mailto: [email protected]
 }
 private static void AddInNotification(List <MembershipLifecycleGroup> listToModifiy, IdentityStoreObject lObject, MembershipLifecycleMember _notifyObject)
 {
     if (!listToModifiy.Any <MembershipLifecycleGroup>((MembershipLifecycleGroup z) => z.get_GUID().Equals(lObject.get_ObjectIdFromIdentityStore())))
     {
         MembershipLifecycleGroup membershipLifecycleGroup = new MembershipLifecycleGroup();
         membershipLifecycleGroup.set_GUID(lObject.get_ObjectIdFromIdentityStore());
         membershipLifecycleGroup.set_DisplayName(lObject.get_ObjectDisplayName());
         membershipLifecycleGroup.set_ObjectType(lObject.get_ObjectType());
         membershipLifecycleGroup.set_MembershiplifeCycleMembers(new List <MembershipLifecycleMember>());
         listToModifiy.Add(membershipLifecycleGroup);
     }
     listToModifiy.First <MembershipLifecycleGroup>((MembershipLifecycleGroup z) => z.get_GUID().Equals(lObject.get_ObjectIdFromIdentityStore())).get_MembershiplifeCycleMembers().Add(_notifyObject);
 }
        public virtual void NotifyTheExpiringGroups(List <IdentityStoreObject> expiringGroups)
        {
            List <string> groupsToNotifyOneDay              = new List <string>();
            List <string> groupsToNotifySevenDays           = new List <string>();
            List <string> groupsToNotifyThirtyDays          = new List <string>();
            List <IdentityStoreObject> groupsToNotifyUpdate = new List <IdentityStoreObject>();

            foreach (IdentityStoreObject group in expiringGroups)
            {
                if (group != null)
                {
                    if (this.IsGroup(group))
                    {
                        IdentityStoreObject parentGroup = this.GetParentGroup(expiringGroups, group);
                        if (parentGroup != null)
                        {
                            if (this.IsGroupInExcludedContainer(parentGroup))
                            {
                                continue;
                            }
                        }
                        else if (this.IsGroupInExcludedContainer(group))
                        {
                            continue;
                        }
                        if (this.ShouldExpireSecurityGroup(group))
                        {
                            if ((this.ExtendedGroups == null || this.ExtendedGroups.Count <= 0 ? true : !this.ExtendedGroups.Contains(group.get_ObjectIdFromIdentityStore())))
                            {
                                int dueDays = 0;
                                if (this.IsNotificationDueOneDay(group, out dueDays))
                                {
                                    groupsToNotifyOneDay.Add(group.get_ObjectIdFromIdentityStore());
                                    groupsToNotifyUpdate.Add(group);
                                }
                                dueDays = 0;
                                if (this.IsNotificationDueSevenDays(group, out dueDays))
                                {
                                    groupsToNotifySevenDays.Add(group.get_ObjectIdFromIdentityStore());
                                    groupsToNotifyUpdate.Add(group);
                                }
                                dueDays = 0;
                                if (this.IsNotificationDueThirtyDays(group, out dueDays))
                                {
                                    groupsToNotifyThirtyDays.Add(group.get_ObjectIdFromIdentityStore());
                                    groupsToNotifyUpdate.Add(group);
                                }
                            }
                        }
                    }
                }
            }
            if ((groupsToNotifyOneDay.Count > 0 || groupsToNotifySevenDays.Count > 0 ? true : groupsToNotifyThirtyDays.Count > 0))
            {
                ServicesGroupServiceClient groupServiceClient = new ServicesGroupServiceClient(false);
                ActionResult result = null;
                if (groupsToNotifyOneDay.Count > 0)
                {
                    result = groupServiceClient.SendGlmNotification(Helper.CurrentTask.get_IdentityStoreId(), 38, groupsToNotifyOneDay);
                    this.LogResults(result, "NotifyTheExpiringGroups-OneDay-Notifications");
                }
                if (groupsToNotifySevenDays.Count > 0)
                {
                    result = groupServiceClient.SendGlmNotification(Helper.CurrentTask.get_IdentityStoreId(), 39, groupsToNotifySevenDays);
                    this.LogResults(result, "NotifyTheExpiringGroups-SevenDays-Notifications");
                }
                if (groupsToNotifyThirtyDays.Count > 0)
                {
                    result = groupServiceClient.SendGlmNotification(Helper.CurrentTask.get_IdentityStoreId(), 40, groupsToNotifyThirtyDays);
                    this.LogResults(result, "NotifyTheExpiringGroups-ThirtyDays-Notifications");
                }
                groupsToNotifyUpdate.ForEach((IdentityStoreObject g) => this.SetAttributeValue("IMGLastSentExpireNotificationDate", DateTime.Now.Date.ToString("yyyy MMMM dd HH:mm:ss"), g.get_AttributesBusinessObject()));
                List <IdentityStoreObject> groupsToUpdate = this.CloneObjectsForUpdate(new List <string>()
                {
                    "IMGLastSentExpireNotificationDate"
                }, groupsToNotifyUpdate, null);
                groupsToUpdate.ForEach((IdentityStoreObject g) => g.set_StopNotification(true));
                string compressedString = DataCompressionHelper.CompressObjects <List <IdentityStoreObject> >(groupsToUpdate);
                result = groupServiceClient.UpdateManyWithCompression(Helper.CurrentTask.get_IdentityStoreId(), compressedString, typeof(IdentityStoreObject).FullName);
                this.LogResults(result, "NotifyTheExpiringGroups-AfterNotificationsUpdate");
            }
        }
        protected virtual bool ReduceLifeForGUS(IdentityStoreObject grp)
        {
            bool     flag;
            DateTime date;

            if ((!Helper.AppConfiguration.get_GUSIsLifecycleEnabled() || !Helper.AppConfiguration.get_GUSReduceGroupsLife() ? true : !grp.get_AttributesBusinessObject().HasValue(Helper.KnownProviderAttributes.get_Alias())))
            {
                flag = false;
            }
            else if (!Helper.AppConfiguration.get_IsGroupAttestationEnabled())
            {
                try
                {
                    string lastProcessed = this.GetAttributeValue("IMGLastProcessedDate", grp.get_AttributesBusinessObject()).get_Value();
                    string lastUsed      = this.GetAttributeValue("IMGLastUsed", grp.get_AttributesBusinessObject()).get_Value();
                    if (!string.IsNullOrEmpty(lastProcessed))
                    {
                        DateTime lastProcessedDate = Helper.ParseDateTime(lastProcessed);
                        if (lastProcessedDate == DateTime.MinValue)
                        {
                            GroupsProcessor.logger.ErrorFormat("ReduceLifeForGUS: Invalid date format {0}", lastProcessedDate);
                            flag = false;
                            return(flag);
                        }
                        else if ((DateTime.Now - lastProcessedDate).Days > 30)
                        {
                            flag = false;
                            return(flag);
                        }
                        else
                        {
                            DateTime lastUsedDate = DateTime.MinValue;
                            if (!string.IsNullOrEmpty(lastUsed))
                            {
                                lastUsedDate = Helper.ParseDateTime(lastUsed);
                            }
                            if (lastUsedDate == DateTime.MinValue)
                            {
                                string expiration = this.GetAttributeValue("XGroupExpirationDate", grp.get_AttributesBusinessObject()).get_Value();
                                if (string.IsNullOrEmpty(expiration))
                                {
                                    flag = false;
                                    return(flag);
                                }
                                else
                                {
                                    DateTime expirationdDate = Helper.ParseDateTime(expiration);
                                    if (expirationdDate.Date == DateTime.MinValue.Date)
                                    {
                                        GroupsProcessor.logger.ErrorFormat("ReduceLifeForGUS: Invalid date format {0}", expirationdDate);
                                        flag = false;
                                        return(flag);
                                    }
                                    else if ((expirationdDate.Date - DateTime.Now.Date).Days <= 7)
                                    {
                                        flag = false;
                                        return(flag);
                                    }
                                    else
                                    {
                                        date = DateTime.Now.AddDays(7);
                                        date = date.Date;
                                        this.SetAttributeValue("XGroupExpirationDate", date.ToString("yyyy MMMM dd HH:mm:ss"), grp.get_AttributesBusinessObject());
                                        date = DateTime.Now;
                                        this.SetAttributeValue("IMGLastRenewedDate", date.ToString(), grp.get_AttributesBusinessObject());
                                        flag = true;
                                        return(flag);
                                    }
                                }
                            }
                            else if ((DateTime.Now - lastUsedDate).Days >= Helper.AppConfiguration.get_GUSUnusedGroupsTime())
                            {
                                string expiration = this.GetAttributeValue("XGroupExpirationDate", grp.get_AttributesBusinessObject()).get_Value();
                                if (string.IsNullOrEmpty(expiration))
                                {
                                    flag = false;
                                    return(flag);
                                }
                                else
                                {
                                    DateTime expirationdDate = Helper.ParseDateTime(expiration);
                                    if (expirationdDate.Date == DateTime.MinValue.Date)
                                    {
                                        GroupsProcessor.logger.ErrorFormat("ReduceLifeForGUS: Invalid date format {0}", expirationdDate);
                                        flag = false;
                                        return(flag);
                                    }
                                    else if ((expirationdDate.Date - DateTime.Now.Date).Days <= 7)
                                    {
                                        flag = false;
                                        return(flag);
                                    }
                                    else
                                    {
                                        date = DateTime.Now.AddDays(7);
                                        date = date.Date;
                                        this.SetAttributeValue("XGroupExpirationDate", date.ToString("yyyy MMMM dd HH:mm:ss"), grp.get_AttributesBusinessObject());
                                        date = DateTime.Now;
                                        this.SetAttributeValue("IMGLastRenewedDate", date.ToString(), grp.get_AttributesBusinessObject());
                                        flag = true;
                                        return(flag);
                                    }
                                }
                            }
                        }
                    }
                    flag = false;
                    return(flag);
                }
                catch (Exception exception)
                {
                    Exception ex = exception;
                    LogExtension.LogException(GroupsProcessor.logger, string.Format("An Error occured while performing GLM Expiry operation on group: {0} Reason: {1}", this.GetAttributeValue(Helper.KnownProviderAttributes.get_DisplayName(), grp.get_AttributesBusinessObject()).get_Value() ?? string.Empty, ex.Message), ex);
                }
                flag = false;
            }
            else
            {
                flag = false;
            }
            return(flag);
        }
Exemple #20
0
        protected virtual bool ExtendLifeForGUS(IdentityStoreObject grp)
        {
            bool     flag;
            DateTime today;

            if ((!Helper.AppConfiguration.get_GUSIsLifecycleEnabled() || !Helper.AppConfiguration.get_GUSExtendGroupsLife() ? true : !grp.get_AttributesBusinessObject().HasValue(Helper.KnownProviderAttributes.get_Alias())))
            {
                flag = false;
            }
            else if (!Helper.AppConfiguration.get_IsGroupAttestationEnabled())
            {
                try
                {
                    string lastUsed = this.GetAttributeValue("IMGLastUsed", grp.get_AttributesBusinessObject()).get_Value();
                    if (string.IsNullOrEmpty(lastUsed))
                    {
                        flag = false;
                        return(flag);
                    }
                    else
                    {
                        DateTime lastUsedDate = Helper.ParseDateTime(lastUsed);
                        if (lastUsedDate == DateTime.MinValue)
                        {
                            GroupsProcessor.logger.ErrorFormat("ExtendLifeForGUS: Invalid date format {0}", lastUsedDate);
                            flag = false;
                            return(flag);
                        }
                        else if ((DateTime.Now - lastUsedDate).Days > Helper.AppConfiguration.get_GUSUsedGroupsTime())
                        {
                            flag = false;
                            return(flag);
                        }
                        else
                        {
                            Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute policyDto = this.GetAttributeValue("XGroupExpirationPolicy", grp.get_AttributesBusinessObject());
                            int      policy       = -1;
                            DateTime extendedDate = DateTime.MaxValue.Date;
                            if (!int.TryParse(policyDto.get_Value() ?? string.Empty, out policy))
                            {
                                policy = Helper.AppConfiguration.get_DefaultExpirationPolicy();
                                if (policy != 0)
                                {
                                    today        = DateTime.Today;
                                    today        = today.AddDays((double)policy);
                                    extendedDate = today.Date;
                                }
                            }
                            else if (policy != 0)
                            {
                                today        = DateTime.Today;
                                today        = today.AddDays((double)policy);
                                extendedDate = today.Date;
                            }
                            this.SetAttributeValue("XGroupExpirationDate", extendedDate.ToString("yyyy MMMM dd HH:mm:ss"), grp.get_AttributesBusinessObject());
                            today = DateTime.Now;
                            this.SetAttributeValue("IMGLastRenewedDate", today.ToString(), grp.get_AttributesBusinessObject());
                            flag = true;
                            return(flag);
                        }
                    }
                }
                catch (Exception exception)
                {
                    Exception ex = exception;
                    LogExtension.LogException(GroupsProcessor.logger, string.Format("An Error occured while performing GLM Extend life operation on group: {0} Reason: {1}", this.GetAttributeValue(Helper.KnownProviderAttributes.get_DisplayName(), grp.get_AttributesBusinessObject()).get_Value() ?? string.Empty, ex.Message), ex);
                }
                flag = false;
            }
            else
            {
                flag = false;
            }
            return(flag);
        }
Exemple #21
0
 public virtual bool IsGlmBlankGroup(IdentityStoreObject group)
 {
     return(group.get_AttributesBusinessObject() == null ? true : !group.get_AttributesBusinessObject().IsIn("XGroupExpirationDate"));
 }
 private static void AddInNotification(List <MembershipLifecycleGroup> AddMemberGroups, IdentityStoreObject lGroup, MembershipLifecycleMember _notifyMember)
 {
     if (!AddMemberGroups.Any <MembershipLifecycleGroup>((MembershipLifecycleGroup z) => z.get_GUID().Equals(lGroup.get_ObjectIdFromIdentityStore())))
     {
         MembershipLifecycleGroup membershipLifecycleGroup = new MembershipLifecycleGroup();
         membershipLifecycleGroup.set_GUID(lGroup.get_ObjectIdFromIdentityStore());
         membershipLifecycleGroup.set_DisplayName(lGroup.get_ObjectDisplayName());
         membershipLifecycleGroup.set_ObjectType(lGroup.get_ObjectType());
         membershipLifecycleGroup.set_MembershiplifeCycleMembers(new List <MembershipLifecycleMember>());
         AddMemberGroups.Add(membershipLifecycleGroup);
     }
     AddMemberGroups.First <MembershipLifecycleGroup>((MembershipLifecycleGroup z) => z.get_GUID().Equals(lGroup.get_ObjectIdFromIdentityStore())).get_MembershiplifeCycleMembers().Add(_notifyMember);
 }
        private static void SmartGroupInclude(List <string> smartGrpIncludes, List <string> smartGrpExcludes, IdentityStoreObject lGroup, Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute lMember)
        {
            KeyValuePair <string, List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> > keyValuePair;

            if ((smartGrpExcludes == null || smartGrpExcludes.Count <= 0 ? false : smartGrpExcludes.Contains(lMember.get_Value())))
            {
                keyValuePair = lGroup.get_AttributesBusinessObject().get_AttributesCollection().FirstOrDefault <KeyValuePair <string, List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> > >((KeyValuePair <string, List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> > e) => StringUtility.EqualsIgnoreCase(e.Key, "IMSGExcludes"));
                keyValuePair.Value.FirstOrDefault <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute>((Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute z) => z.get_Value().Equals(lMember.get_Value())).set_Action(2);
            }
            if ((smartGrpIncludes == null || smartGrpIncludes.Count <= 0 ? !lGroup.get_AttributesBusinessObject().get_AttributesCollection().ContainsKey("IMSGIncludes") : false))
            {
                Dictionary <string, List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> > attributesCollection = lGroup.get_AttributesBusinessObject().get_AttributesCollection();
                List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> attributes = new List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute>();
                Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute        attribute  = new Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute();
                attribute.set_Action(1);
                attribute.set_Value(lMember.get_Value());
                attributes.Add(attribute);
                attributesCollection.Add("IMSGIncludes", attributes);
            }
            else
            {
                keyValuePair = lGroup.get_AttributesBusinessObject().get_AttributesCollection().FirstOrDefault <KeyValuePair <string, List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> > >((KeyValuePair <string, List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> > e) => StringUtility.EqualsIgnoreCase(e.Key, "IMSGIncludes"));
                List <Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute> value      = keyValuePair.Value;
                Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute        attribute1 = new Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute();
                attribute1.set_Action(1);
                attribute1.set_Value(lMember.get_Value());
                value.Add(attribute1);
            }
        }
Exemple #24
0
 public virtual bool ExtendGroupLife(DateTime newDate, IdentityStoreObject group)
 {
     Imanami.GroupID.DataTransferObjects.DataContracts.Services.Attribute expirationDateDto = this.GetAttributeValue("XGroupExpirationDate", group.get_AttributesBusinessObject());
     expirationDateDto.set_Value(newDate.Date.ToString("yyyy MMMM dd HH:mm:ss"));
     return(true);
 }