public virtual void DeleteExpiredGroups(List <IdentityStoreObject> groups) { LogExtension.EnterMethod(GroupsProcessor.logger, MethodBase.GetCurrentMethod(), new object[0]); List <string> groupsToNotify = new List <string>(); List <IdentityStoreObject> groupsToDelete = new List <IdentityStoreObject>(); try { foreach (IdentityStoreObject group in groups) { try { if (!this.IsGroup(group)) { GroupsProcessor.logger.DebugFormat("DeleteExpiredGroups. Object {0} is not a group.", this.GetAttributeValue(Helper.KnownProviderAttributes.get_Name(), group.get_AttributesBusinessObject()).get_Value() ?? string.Empty); continue; } else if (this.IsSystemGroup(group)) { GroupsProcessor.logger.DebugFormat("DeleteExpiredGroups. Object {0} is a system group.", this.GetAttributeValue(Helper.KnownProviderAttributes.get_Name(), group.get_AttributesBusinessObject()).get_Value() ?? string.Empty); continue; } else if (this.IsGroupInExcludedContainer(group)) { GroupsProcessor.logger.DebugFormat("DeleteExpiredGroups. Object {0} is in excluded containers.", this.GetAttributeValue(Helper.KnownProviderAttributes.get_Name(), group.get_AttributesBusinessObject()).get_Value() ?? string.Empty); continue; } else if (this.ShouldExpireSecurityGroup(group)) { string expirationDateString = this.GetAttributeValue("XGroupExpirationDate", group.get_AttributesBusinessObject()).get_Value(); DateTime expirationDate = Helper.ParseDateTime(expirationDateString); if (expirationDate.Date == DateTime.MinValue.Date) { continue; } else if (DateTime.Now.Date.Subtract(expirationDate.Date).Days >= Helper.AppConfiguration.get_DeletionDaysAfterExpiry()) { this.SetAttributeValue("IMGIsDeleted", "true", group.get_AttributesBusinessObject()); string updatedDisplayName = this.GetUpdatedDisplayName(group); group.set_ObjectDisplayName(updatedDisplayName); this.SetAttributeValue(Helper.KnownProviderAttributes.get_DisplayName(), updatedDisplayName, group.get_AttributesBusinessObject()); groupsToNotify.Add(group.get_ObjectIdFromIdentityStore()); groupsToDelete.Add(group); GroupsProcessor.logger.InfoFormat("Group Deleted: {0}", group.get_ObjectDisplayName()); } else { continue; } } else { GroupsProcessor.logger.DebugFormat("DeleteExpiredGroups. Object {0} is a security group.", this.GetAttributeValue(Helper.KnownProviderAttributes.get_Name(), group.get_AttributesBusinessObject()).get_Value() ?? string.Empty); continue; } } catch (Exception exception) { Exception ex = exception; GroupsProcessor.logger.Error(string.Format("An Error occured while performing deletion operation on group: {0} Reason: {1}", this.GetAttributeValue(Helper.KnownProviderAttributes.get_DistinguishedName(), group.get_AttributesBusinessObject()).get_Value() ?? string.Empty, ex.Message), ex); } } ServicesGroupServiceClient groupServiceClient = new ServicesGroupServiceClient(false); if (groupsToDelete.Count > 0) { groupsToDelete.ForEach((IdentityStoreObject g) => this.SetAttributeValue("IMGLastSentExpireNotificationDate", DateTime.Now.Date.ToString("yyyy MMMM dd HH:mm:ss"), g.get_AttributesBusinessObject())); groupsToDelete.ForEach((IdentityStoreObject g) => this.SetAttributeValue("IMGIsDeleted", "TRUE", g.get_AttributesBusinessObject())); List <IdentityStoreObject> groupsToUpdate = this.CloneObjectsForUpdate(new List <string>() { "IMGLastSentExpireNotificationDate", "IMGIsDeleted", Helper.KnownProviderAttributes.get_DisplayName() }, groupsToDelete, null); string compressedString = DataCompressionHelper.CompressObjects <List <IdentityStoreObject> >(groupsToUpdate); ActionResult result = groupServiceClient.UpdateManyWithCompression(Helper.CurrentTask.get_IdentityStoreId(), compressedString, typeof(IdentityStoreObject).FullName); this.LogResults(result, "DeleteExpiredGroups"); } if (groupsToNotify.Count > 0) { ActionResult result = groupServiceClient.SendGlmNotification(Helper.CurrentTask.get_IdentityStoreId(), 29, groupsToNotify); this.LogResults(result, "DeleteExpiredGroups-Notifications"); } LogExtension.ExitMethod(GroupsProcessor.logger, MethodBase.GetCurrentMethod(), new object[0]); } catch (Exception exception1) { Exception Ex = exception1; LogExtension.LogException(GroupsProcessor.logger, string.Format("An error ocurred while deleting 30 days old expired groups: {0}", Ex.Message), Ex); } }