Ejemplo n.º 1
0
        internal static AdTagData FetchTagContentSettings(RetentionPolicyTag retentionPolicyTag)
        {
            AdTagData adTagData = new AdTagData();

            adTagData.Tag = new RetentionTag(retentionPolicyTag);
            List <ElcContentSettings> list = new List <ElcContentSettings>(retentionPolicyTag.GetELCContentSettings().ReadAllPages());

            foreach (ElcContentSettings elcContentSettings in list)
            {
                ValidationError[] array = elcContentSettings.ValidateRead();
                if (array != null && array.Length > 0)
                {
                    ValidationError[] array2 = array;
                    int num = 0;
                    if (num < array2.Length)
                    {
                        ValidationError validationError = array2[num];
                        AdReader.Tracer.TraceError <string, LocalizedString>(0L, "The ElcContentSettings '{0}' has a validation error: {1}", elcContentSettings.Name, validationError.Description);
                        throw new DataValidationException(validationError);
                    }
                }
            }
            adTagData.ContentSettings = new SortedDictionary <Guid, ContentSetting>();
            foreach (ElcContentSettings elcContentSettings2 in list)
            {
                adTagData.ContentSettings[elcContentSettings2.Guid] = new ContentSetting(elcContentSettings2);
            }
            return(adTagData);
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Load from xml.
    /// </summary>
    /// <param name="reader">The reader.</param>
    /// <returns>Retention policy tag object.</returns>
    static RetentionPolicyTag LoadFromXml(EwsServiceXmlReader reader)
    {
        reader.EnsureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.RetentionPolicyTag);

        RetentionPolicyTag retentionPolicyTag = new RetentionPolicyTag();

        retentionPolicyTag.DisplayName     = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.DisplayName);
        retentionPolicyTag.RetentionId     = new Guid(reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.RetentionId));
        retentionPolicyTag.RetentionPeriod = reader.ReadElementValue <int>(XmlNamespace.Types, XmlElementNames.RetentionPeriod);
        retentionPolicyTag.Type            = reader.ReadElementValue <ElcFolderType>(XmlNamespace.Types, XmlElementNames.Type);
        retentionPolicyTag.RetentionAction = reader.ReadElementValue <RetentionActionType>(XmlNamespace.Types, XmlElementNames.RetentionAction);

        // Description is not a required property.
        reader.Read();
        if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.Description))
        {
            retentionPolicyTag.Description = reader.ReadElementValue(XmlNamespace.Types, XmlElementNames.Description);
        }

        retentionPolicyTag.IsVisible = reader.ReadElementValue <bool>(XmlNamespace.Types, XmlElementNames.IsVisible);
        retentionPolicyTag.OptedInto = reader.ReadElementValue <bool>(XmlNamespace.Types, XmlElementNames.OptedInto);
        retentionPolicyTag.IsArchive = reader.ReadElementValue <bool>(XmlNamespace.Types, XmlElementNames.IsArchive);

        return(retentionPolicyTag);
    }
Ejemplo n.º 3
0
 internal RetentionTag(RetentionPolicyTag retentionPolicyTag)
 {
     this.guid          = retentionPolicyTag.Guid;
     this.effectiveGuid = retentionPolicyTag.RetentionId;
     this.name          = retentionPolicyTag.Name;
     this.localizedRetentionPolicyTagName = retentionPolicyTag.LocalizedRetentionPolicyTagName.ToArray();
     this.comment                   = retentionPolicyTag.Comment;
     this.localizedComment          = retentionPolicyTag.LocalizedComment.ToArray();
     this.type                      = retentionPolicyTag.Type;
     this.isPrimary                 = retentionPolicyTag.IsPrimary;
     this.mustDisplayCommentEnabled = retentionPolicyTag.MustDisplayCommentEnabled;
     if (retentionPolicyTag.LegacyManagedFolder != null)
     {
         this.legacyManagedFolder = new Guid?(retentionPolicyTag.LegacyManagedFolder.ObjectGuid);
     }
 }
Ejemplo n.º 4
0
    void ReadElementsFromXml(EwsServiceXmlReader reader)
    {
        this.retentionPolicyTags.Clear();

        base.ReadElementsFromXml(reader);

        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.RetentionPolicyTags);
        if (!reader.IsEmptyElement)
        {
            do
            {
                reader.Read();
                if (reader.IsStartElement(XmlNamespace.Types, XmlElementNames.RetentionPolicyTag))
                {
                    this.retentionPolicyTags.Add(RetentionPolicyTag.LoadFromXml(reader));
                }
            }while (!reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.RetentionPolicyTags));
            reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.RetentionPolicyTags);
        }
    }
        public static void ClearDefaultPolicyTag(IConfigurationSession session, IList <RetentionPolicyTag> defaultPolicies, ApprovalApplicationId approvalApplicationType)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session is null probably due to not of IConfigurationSession type");
            }
            if (defaultPolicies != null && defaultPolicies.Count > 0)
            {
                switch (approvalApplicationType)
                {
                case ApprovalApplicationId.AutoGroup:
                    using (IEnumerator <RetentionPolicyTag> enumerator = defaultPolicies.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            RetentionPolicyTag retentionPolicyTag = enumerator.Current;
                            retentionPolicyTag.IsDefaultAutoGroupPolicyTag = false;
                            session.Save(retentionPolicyTag);
                        }
                        return;
                    }
                    break;

                case ApprovalApplicationId.ModeratedRecipient:
                    break;

                default:
                    return;
                }
                foreach (RetentionPolicyTag retentionPolicyTag2 in defaultPolicies)
                {
                    retentionPolicyTag2.IsDefaultModeratedRecipientsPolicyTag = false;
                    session.Save(retentionPolicyTag2);
                }
            }
        }
 public RetentionPolicyTagIdParameter(RetentionPolicyTag policyTag) : base(policyTag.Id)
 {
 }
Ejemplo n.º 7
0
        private void StampModeratedTransportExpiry()
        {
            byte[]            policyTag         = null;
            string            text              = string.Empty;
            int               retentionPeriod   = 2;
            ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate()
            {
                IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.mbxTransportMailItem.OrganizationId), 361, "StampModeratedTransportExpiry", "f:\\15.00.1497\\sources\\dev\\MailboxTransport\\src\\MailboxTransportDelivery\\StoreDriver\\agents\\approval\\ApprovalEngine.cs");
                ADObjectId descendantId = tenantOrTopologyConfigurationSession.GetOrgContainerId().GetDescendantId(ApprovalApplication.ParentPathInternal);
                ADObjectId childId      = descendantId.GetChildId("ModeratedRecipients");
                ApprovalEngine.diag.TraceDebug <ADObjectId>((long)this.GetHashCode(), "Reading ModeratedRecipient app from {0}", childId);
                if (childId != null)
                {
                    ApprovalApplication approvalApplication = tenantOrTopologyConfigurationSession.Read <ApprovalApplication>(childId);
                    if (approvalApplication != null)
                    {
                        ADObjectId elcretentionPolicyTag = approvalApplication.ELCRetentionPolicyTag;
                        ApprovalEngine.diag.TraceDebug <ADObjectId>((long)this.GetHashCode(), "Read ModeratedRecipient, now reading Recipient Policy Tag {0}", elcretentionPolicyTag);
                        RetentionPolicyTag retentionPolicyTag = null;
                        if (elcretentionPolicyTag != null)
                        {
                            retentionPolicyTag = tenantOrTopologyConfigurationSession.Read <RetentionPolicyTag>(elcretentionPolicyTag);
                        }
                        else
                        {
                            IConfigurationSession configurationSession = SharedConfiguration.CreateScopedToSharedConfigADSession(this.mbxTransportMailItem.OrganizationId);
                            if (configurationSession != null)
                            {
                                IList <RetentionPolicyTag> defaultRetentionPolicyTag = ApprovalUtils.GetDefaultRetentionPolicyTag(configurationSession, ApprovalApplicationId.ModeratedRecipient, 1);
                                if (defaultRetentionPolicyTag != null && defaultRetentionPolicyTag.Count > 0)
                                {
                                    retentionPolicyTag = defaultRetentionPolicyTag[0];
                                }
                            }
                        }
                        if (retentionPolicyTag != null)
                        {
                            ADPagedReader <ElcContentSettings> elccontentSettings = retentionPolicyTag.GetELCContentSettings();
                            using (IEnumerator <ElcContentSettings> enumerator = elccontentSettings.GetEnumerator())
                            {
                                if (enumerator.MoveNext())
                                {
                                    ElcContentSettings elcContentSettings = enumerator.Current;
                                    retentionPeriod = (int)elcContentSettings.AgeLimitForRetention.Value.TotalDays;
                                }
                            }
                            policyTag = retentionPolicyTag.RetentionId.ToByteArray();
                        }
                    }
                }
            });

            if (!adoperationResult.Succeeded)
            {
                if (adoperationResult.Exception is TransientException)
                {
                    throw adoperationResult.Exception;
                }
                text = adoperationResult.Exception.ToString();
                ApprovalEngine.diag.TraceError <string>((long)this.GetHashCode(), "Can't get PolicyTag guid {0}, NDRing.", text);
            }
            if (policyTag == null)
            {
                ApprovalEngine.diag.TraceError((long)this.GetHashCode(), "PolicyTag not read. NDRing");
                string text2 = this.mbxTransportMailItem.OrganizationId.ToString();
                StoreDriverDeliveryDiagnostics.LogEvent(MailboxTransportEventLogConstants.Tuple_ApprovalCannotStampExpiry, text2, new object[]
                {
                    text2,
                    text
                });
                throw new SmtpResponseException(AckReason.ApprovalCannotReadExpiryPolicy);
            }
            if (retentionPeriod < 2)
            {
                retentionPeriod = 2;
            }
            else if (retentionPeriod > 30)
            {
                retentionPeriod = 30;
            }
            this.messageItem[ItemSchema.RetentionDate]          = ExDateTime.UtcNow.AddDays((double)retentionPeriod);
            this.messageItem[StoreObjectSchema.RetentionPeriod] = retentionPeriod;
            this.messageItem[StoreObjectSchema.PolicyTag]       = policyTag;
        }
Ejemplo n.º 8
0
 public PresentationRetentionPolicyTag(RetentionPolicyTag retentionPolicyTag, ElcContentSettings contentSettings)
 {
     this.propertyBag     = retentionPolicyTag.propertyBag;
     this.m_Session       = retentionPolicyTag.m_Session;
     this.contentSettings = contentSettings;
 }
Ejemplo n.º 9
0
 public PresentationRetentionPolicyTag(RetentionPolicyTag retentionPolicyTag)
 {
     this.propertyBag     = retentionPolicyTag.propertyBag;
     this.m_Session       = retentionPolicyTag.m_Session;
     this.contentSettings = retentionPolicyTag.GetELCContentSettings().FirstOrDefault <ElcContentSettings>();
 }
        protected string SubmitApprovalRequest(string command)
        {
            if (this.DataObject.ArbitrationMailbox == null)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorArbitrationMailboxNotSet(this.Identity.ToString())), ErrorCategory.InvalidArgument, this.Identity);
            }
            ADRecipient adrecipient = (ADRecipient)base.GetDataObject <ADRecipient>(new MailboxIdParameter(this.DataObject.ArbitrationMailbox), base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.DataObject.ArbitrationMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.DataObject.ArbitrationMailbox.ToString())));

            if (adrecipient.RecipientTypeDetails != RecipientTypeDetails.ArbitrationMailbox)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorInvalidArbitrationMbxType(adrecipient.Identity.ToString())), ErrorCategory.InvalidData, this.DataObject.Identity);
            }
            if (!adrecipient.IsValid)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorInvalidArbitrationMailbox(adrecipient.Identity.ToString())), ErrorCategory.InvalidData, this.DataObject.Identity);
            }
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, ApprovalApplicationSchema.ArbitrationMailboxesBacklink, adrecipient.Id),
                new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, "AutoGroup")
            });

            ApprovalApplication[] array = this.ConfigurationSession.Find <ApprovalApplication>(null, QueryScope.SubTree, filter, null, 1);
            if (array == null || array.Length == 0)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorNoAutoGroupApprovalApplicationInOrg(adrecipient.OrganizationId.ToString())), ErrorCategory.InvalidData, null);
            }
            Guid policyTag       = Guid.Empty;
            int? retentionPeriod = null;
            RetentionPolicyTag retentionPolicyTag = null;

            if (array[0].ELCRetentionPolicyTag != null)
            {
                this.ConfigurationSession.SessionSettings.IsSharedConfigChecked = true;
                retentionPolicyTag = this.ConfigurationSession.Read <RetentionPolicyTag>(array[0].ELCRetentionPolicyTag);
            }
            else
            {
                IConfigurationSession configurationSession = SharedConfiguration.CreateScopedToSharedConfigADSession(adrecipient.OrganizationId);
                if (configurationSession != null)
                {
                    IList <RetentionPolicyTag> defaultRetentionPolicyTag = ApprovalUtils.GetDefaultRetentionPolicyTag(configurationSession, ApprovalApplicationId.AutoGroup, 1);
                    if (defaultRetentionPolicyTag != null && defaultRetentionPolicyTag.Count > 0)
                    {
                        retentionPolicyTag = defaultRetentionPolicyTag[0];
                    }
                }
            }
            if (retentionPolicyTag == null)
            {
                this.WriteWarning(Strings.WarningRetentionPolicyTagNotFoundForApproval(array[0].Name, adrecipient.OrganizationId.ToString()));
            }
            else
            {
                policyTag = retentionPolicyTag.RetentionId;
                EnhancedTimeSpan?timeSpanForRetention = retentionPolicyTag.TimeSpanForRetention;
                retentionPeriod = ((timeSpanForRetention != null) ? new int?((int)timeSpanForRetention.Value.TotalDays) : null);
            }
            Result <ADRawEntry>[] array2 = base.TenantGlobalCatalogSession.ReadMultiple(this.DataObject.ManagedBy.ToArray(), new PropertyDefinition[]
            {
                ADObjectSchema.Id,
                ADRecipientSchema.PrimarySmtpAddress,
                ADUserSchema.Languages,
                ADRecipientSchema.RecipientTypeDetails
            });
            ADRawEntry[] array3 = new ADRawEntry[array2.Length];
            for (int i = 0; i < array3.Length; i++)
            {
                array3[i] = array2[i].Data;
            }
            SmtpAddress[] array4 = (from approver in array3
                                    where (RecipientTypeDetails)approver[ADRecipientSchema.RecipientTypeDetails] != RecipientTypeDetails.MailUniversalSecurityGroup && (RecipientTypeDetails)approver[ADRecipientSchema.RecipientTypeDetails] != RecipientTypeDetails.UniversalSecurityGroup
                                    select(SmtpAddress) approver[ADRecipientSchema.PrimarySmtpAddress]).ToArray <SmtpAddress>();
            if (array4.Length == 0)
            {
                base.WriteError(new RecipientTaskException(Strings.ErrorApproversNotSet(this.Identity.ToString())), ErrorCategory.InvalidArgument, this.Identity);
            }
            base.WriteVerbose(Strings.VerboseStartToSubmitApprovalRequest(this.DataObject.DisplayName, string.Join <SmtpAddress>(", ", array4)));
            CultureInfo moderatorCommonCulture = this.SelectApproverCommonCulture(array3);
            string      text = ApprovalProcessor.SubmitRequest(0, adrecipient.PrimarySmtpAddress, this.requester.PrimarySmtpAddress, array4, moderatorCommonCulture, policyTag, retentionPeriod, this.ApprovalMessageSubject(), AutoGroupApplication.BuildApprovalData(command, this.DataObject.Id));

            base.WriteVerbose(Strings.VerboseApprovalRequestSubmitted(this.DataObject.DisplayName, text));
            return(text);
        }