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); } }
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); }
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); }
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); }
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); }
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 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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
public virtual bool IsGlmBlankGroup(IdentityStoreObject group) { return(group.get_AttributesBusinessObject() == null ? true : !group.get_AttributesBusinessObject().IsIn("XGroupExpirationDate")); }