Exemple #1
0
        // Token: 0x06000498 RID: 1176 RVA: 0x00021494 File Offset: 0x0001F694
        private bool UpdateArchiveTag(object[] itemProperties, out Guid effectiveGuid)
        {
            bool result = false;
            Guid value  = ElcMailboxHelper.GetGuidFromBytes(itemProperties[this.propertyIndexHolder.ArchiveTagIndex], new Guid?(Guid.Empty), false, base.FolderDisplayName).Value;
            Guid value2 = ElcMailboxHelper.GetGuidFromBytes(itemProperties[this.propertyIndexHolder.ExplicitArchiveTagIndex], new Guid?(Guid.Empty), true, (VersionedId)itemProperties[this.propertyIndexHolder.IdIndex]).Value;

            effectiveGuid = Guid.Empty;
            bool flag  = !Guid.Empty.Equals(value);
            bool flag2 = itemProperties[this.propertyIndexHolder.ArchivePeriodIndex] is int;
            bool flag3 = flag && base.ElcUserTagInformation.ContainsTag(value);
            bool flag4 = this.inheritedArchiveGuid != null && !Guid.Empty.Equals(this.inheritedArchiveGuid.Value);

            if (!value2.Equals(Guid.Empty) && base.ElcUserTagInformation.ContainsTag(value2))
            {
                result        = true;
                effectiveGuid = value2;
                base.AddAdriftTagToFai(value2);
                base.PropertiesToBeDeleted.Add(StoreObjectSchema.ExplicitArchiveTag);
                base.PropertiesToBeUpdated.Add(StoreObjectSchema.ArchiveTag, effectiveGuid.ToByteArray());
                itemProperties[this.propertyIndexHolder.ArchivePeriodIndex] = 1;
                ELCPerfmon.TotalItemsWithPersonalTag.Increment();
                this.taggedByPersonalArchiveTag = true;
            }
            else if (flag && flag3 && flag2)
            {
                effectiveGuid = value;
                base.AddAdriftTagToFai(value);
            }
            else if (flag4 && (!flag || !flag2 || (flag && !flag3)))
            {
                if (flag && flag2 && !flag3)
                {
                    base.PropertiesToBeUpdated.Add(StoreObjectSchema.ExplicitArchiveTag, value.ToByteArray());
                    base.AddDeletedTag(value);
                }
                if (!this.inheritedArchiveGuid.Equals(value))
                {
                    result = true;
                    base.PropertiesToBeUpdated.Add(StoreObjectSchema.ArchiveTag, this.inheritedArchiveGuid.Value.ToByteArray());
                    if (base.ElcUserTagInformation.GetTag(this.inheritedArchiveGuid.Value).Tag.Type == ElcFolderType.Personal)
                    {
                        ELCPerfmon.TotalItemsWithPersonalTag.Increment();
                        this.taggedByPersonalArchiveTag = true;
                    }
                    else
                    {
                        ELCPerfmon.TotalItemsWithDefaultTag.Increment();
                        PropertySynchronizerBase.Tracer.TraceDebug <ItemPropertySynchronizer>((long)this.GetHashCode(), "{0}: Found item with default archive tag", this);
                    }
                }
                effectiveGuid = this.inheritedArchiveGuid.Value;
            }
            else if (flag)
            {
                result = true;
                base.PropertiesToBeDeleted.Add(StoreObjectSchema.ArchiveTag);
                this.taggedByPersonalArchiveTag = true;
            }
            return(result);
        }
Exemple #2
0
        // Token: 0x060003C2 RID: 962 RVA: 0x0001A7F0 File Offset: 0x000189F0
        private bool FaiExists(MailboxSession mailboxSession)
        {
            UserConfiguration userConfiguration = ElcMailboxHelper.OpenFaiMessage(mailboxSession, "MRM", true);

            if (userConfiguration == null)
            {
                ElcSubAssistant.Tracer.TraceDebug((long)this.GetHashCode(), "FAI cannot be found or created.");
                return(false);
            }
            Dictionary <Guid, StoreTagData> dictionary = null;

            try
            {
                dictionary = MrmFaiFormatter.Deserialize(userConfiguration, mailboxSession.MailboxOwner);
            }
            catch (ObjectNotFoundException arg)
            {
                ElcSubAssistant.Tracer.TraceDebug <ObjectNotFoundException>((long)this.GetHashCode(), "Deserialize of MRM FAI message failed because it could not be found. Exception: {0}", arg);
                return(false);
            }
            finally
            {
                if (userConfiguration != null)
                {
                    userConfiguration.Dispose();
                }
            }
            return(dictionary != null && dictionary.Count > 0);
        }
Exemple #3
0
        // Token: 0x0600044C RID: 1100 RVA: 0x0001ECCC File Offset: 0x0001CECC
        private Guid GetParentTag()
        {
            PropertySynchronizerBase.Tracer.TraceDebug <FolderPropertySynchronizer, string>((long)this.GetHashCode(), "{0}: Start searching parent retention tag for folder: {1}", this, base.FolderDisplayName);
            Guid result = Guid.Empty;

            for (int i = this.indexInTree - 1; i >= 0; i--)
            {
                if (((VersionedId)this.entireFolderList[i][0]).ObjectId.Equals((StoreObjectId)this.entireFolderList[this.indexInTree][5]))
                {
                    result = ElcMailboxHelper.GetGuidFromBytes(this.entireFolderList[i][2], new Guid?(Guid.Empty), false, base.FolderDisplayName).Value;
                    PropertySynchronizerBase.Tracer.TraceDebug <FolderPropertySynchronizer, object>((long)this.GetHashCode(), "{0}: Found parent tag from parent folder: {1}", this, this.entireFolderList[i][1]);
                    break;
                }
            }
            if (this.parentFolderIdToPropertyMap != null && result.Equals(Guid.Empty))
            {
                PropertySynchronizerBase.Tracer.TraceDebug <FolderPropertySynchronizer>((long)this.GetHashCode(), "{0}: Cannot find parent in the current folder list. Try to find parent in parentFolderIdToPropertyMap", this);
                Synchronizer.FolderPropertySet folderPropertySet;
                if (this.parentFolderIdToPropertyMap.TryGetValue((StoreObjectId)this.entireFolderList[this.indexInTree][5], out folderPropertySet))
                {
                    result = ElcMailboxHelper.GetGuidFromBytes(folderPropertySet.PolicyTagProperty, new Guid?(Guid.Empty), false, base.FolderDisplayName).Value;
                    PropertySynchronizerBase.Tracer.TraceDebug <FolderPropertySynchronizer>((long)this.GetHashCode(), "{0}: Found parent in parentFolderIdToPropertyMap", this);
                }
            }
            return(result);
        }
Exemple #4
0
        private void LogonPrimary(ExchangePrincipal primaryEP)
        {
            using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(primaryEP, CultureInfo.InvariantCulture, "Client=Monitoring;Action=Test-ArchiveConnectivity"))
            {
                if (mailboxSession != null)
                {
                    UserConfiguration userConfiguration = ElcMailboxHelper.OpenFaiMessage(mailboxSession, "MRM", false);
                    if (userConfiguration != null)
                    {
                        using (Stream xmlStream = userConfiguration.GetXmlStream())
                        {
                            using (StreamReader streamReader = new StreamReader(xmlStream))
                            {
                                this.primaryFAI = streamReader.ReadToEnd();
                            }
                            goto IL_63;
                        }
                    }
                    this.primaryFAI = "No FAI found in Primary Mailbox.";
IL_63:
                    this.primaryLastProcessedTime = this.ReadMailboxTableProperties(mailboxSession);
                    if (!string.IsNullOrEmpty(this.MessageId))
                    {
                        this.GetELCItemProperties(mailboxSession, this.MessageId);
                    }
                }
            }
        }
Exemple #5
0
        // Token: 0x06000442 RID: 1090 RVA: 0x0001DEA0 File Offset: 0x0001C0A0
        private void UpdateFolderProperties()
        {
            if (!(base.FolderProperties[0] is VersionedId))
            {
                PropertySynchronizerBase.Tracer.TraceError <FolderPropertySynchronizer>((long)this.GetHashCode(), "{0}: We could not get id of this folder.", this);
                throw new SkipException(Strings.descUnableToGetId("Folder:" + base.FolderDisplayName, base.ElcUserTagInformation.MailboxSession.MailboxOwner.ToString()));
            }
            Guid guid       = Guid.Empty;
            bool tagChanged = false;

            this.taggedByPersonalArchiveTag = false;
            this.taggedByPersonalExpiryTag  = false;
            this.taggedBySystemExpiryTag    = false;
            this.taggedByUncertainExpiryTag = false;
            DefaultFolderType?defaultFolderType = ElcMailboxHelper.GetDefaultFolderType(base.ElcUserTagInformation.MailboxSession, ((VersionedId)base.FolderProperties[0]).ObjectId);

            if (defaultFolderType != null)
            {
                guid = this.UpdateSystemFolder(defaultFolderType, out tagChanged);
            }
            else
            {
                guid = this.UpdatePersonalFolder(out tagChanged);
            }
            this.UpdateContentSettings(tagChanged, guid);
            this.UpdateArchiveSettings();
            this.UpdateRetentionFlags(guid);
            this.CommitChangesAlready();
        }
Exemple #6
0
        // Token: 0x06000194 RID: 404 RVA: 0x0000BCC0 File Offset: 0x00009EC0
        private Unlimited <EnhancedTimeSpan>?GetLegacyLitigationHoldDuration(out ElcMailboxHelper.ConfigState state)
        {
            state = ElcMailboxHelper.ConfigState.Unknown;
            Unlimited <EnhancedTimeSpan> value;
            Exception ex;

            ElcMailboxHelper.TryGetExistingHoldDurationInStore(this.mailboxSession.MailboxOwner, this.mailboxSession.ClientInfoString, out value, out state, out ex);
            if (state == ElcMailboxHelper.ConfigState.Found)
            {
                return(new Unlimited <EnhancedTimeSpan>?(value));
            }
            if (ex != null)
            {
                ElcUserInformation.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Unable to retrieve litigation hold duration for this mailbox.", this.mailboxSession.MailboxOwner);
                Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_FailedToReadLitigationHoldDurationFromPrimaryMailbox, null, new object[]
                {
                    this.mailboxSession.MailboxOwner
                });
            }
            else
            {
                ElcUserInformation.Tracer.TraceDebug <IExchangePrincipal, string>((long)this.GetHashCode(), "{0}: Unable to retrieve litigation hold duration for this mailbox. ConfigState is {1}. No error encountered", this.mailboxSession.MailboxOwner, state.ToString());
            }
            return(new Unlimited <EnhancedTimeSpan>?(Unlimited <EnhancedTimeSpan> .UnlimitedValue));
        }
        // Token: 0x060001FB RID: 507 RVA: 0x0000D534 File Offset: 0x0000B734
        public bool IsEHAHiddenFolderWatermarkSet()
        {
            ElcMailboxHelper.ConfigState configState;
            Exception ex;

            ElcMailboxHelper.TryGetEHAHiddenFolderCleanupWatermarkInStore(this.mailboxSession.MailboxOwner, this.mailboxSession.ClientInfoString, out configState, out ex);
            return(ex == null && configState == ElcMailboxHelper.ConfigState.Found);
        }
        // Token: 0x06000605 RID: 1541 RVA: 0x0002E5C8 File Offset: 0x0002C7C8
        private void SetWatermark(DefaultFolderType folder, string internetMessageId)
        {
            Exception arg = null;

            if (!ElcMailboxHelper.UpdateHoldCleanupWatermarkFAIMessage(folder, internetMessageId, base.MailboxDataForTags.MailboxSession.ClientInfoString, base.MailboxDataForTags.MailboxSession.MailboxOwner, out arg))
            {
                HoldCleanupEnforcer.Tracer.TraceError <HoldCleanupEnforcer, Exception>((long)this.GetHashCode(), "{0}: Unable to save the watermark due to {1}.", this, arg);
            }
        }
        // Token: 0x060003DC RID: 988 RVA: 0x0001BE44 File Offset: 0x0001A044
        internal UpgradeStatus UpgradeIfNecessary()
        {
            UpgradeStatus result = UpgradeStatus.None;

            if (this.MailboxNeedsUpgrading())
            {
                ElcMailboxHelper.UpgradeElcMailbox(this.dataForTags.MailboxSession, this.dataForTags.AllAdTags, out result);
            }
            return(result);
        }
Exemple #10
0
        // Token: 0x06000446 RID: 1094 RVA: 0x0001E360 File Offset: 0x0001C560
        private void UpdateArchiveSettings()
        {
            PropertySynchronizerBase.Tracer.TraceDebug <FolderPropertySynchronizer>((long)this.GetHashCode(), "{0}: Processing archive tag on a folderfolder.", this);
            Guid           value          = ElcMailboxHelper.GetGuidFromBytes(base.FolderProperties[7], new Guid?(Guid.Empty), false, base.FolderDisplayName).Value;
            Guid           value2         = ElcMailboxHelper.GetGuidFromBytes(base.FolderProperties[10], new Guid?(Guid.Empty), false, base.FolderDisplayName).Value;
            ContentSetting contentSetting = null;

            this.effectiveArchiveGuid = null;
            if (value2 != Guid.Empty)
            {
                if (base.ElcUserTagInformation.ContainsTag(value2))
                {
                    contentSetting = base.ElcUserTagInformation.GetRetentionEnabledSettingForTag(value2);
                    base.PropertiesToBeDeleted.Add(StoreObjectSchema.ExplicitArchiveTag);
                    this.effectiveArchiveGuid = new Guid?(value2);
                    base.PropertiesToBeUpdated.Add(StoreObjectSchema.ArchiveTag, this.effectiveArchiveGuid.Value.ToByteArray());
                    base.AddAdriftTagToFai(value2);
                    this.taggedByPersonalArchiveTag = true;
                }
            }
            else if (value != Guid.Empty)
            {
                if (base.ElcUserTagInformation.ContainsTag(value))
                {
                    contentSetting            = base.ElcUserTagInformation.GetRetentionEnabledSettingForTag(value);
                    this.effectiveArchiveGuid = new Guid?(value);
                    base.AddAdriftTagToFai(value);
                }
                else
                {
                    base.PropertiesToBeUpdated.Add(StoreObjectSchema.ExplicitArchiveTag, value.ToByteArray());
                    base.PropertiesToBeDeleted.Add(StoreObjectSchema.ArchiveTag);
                    base.AddDeletedTag(value);
                    this.taggedByPersonalArchiveTag = true;
                }
            }
            this.explicitArchive = FlagsMan.IsExplicitArchiveSet(this.originalRetentionFlags);
            if (contentSetting != null && contentSetting.AgeLimitForRetention != null)
            {
                int num = (int)contentSetting.AgeLimitForRetention.Value.TotalDays;
                if (base.FolderProperties[8] is int)
                {
                    int num2 = (int)base.FolderProperties[8];
                    if (num != num2)
                    {
                        base.PropertiesToBeUpdated.Add(StoreObjectSchema.ArchivePeriod, num);
                        return;
                    }
                }
                else
                {
                    base.PropertiesToBeUpdated.Add(StoreObjectSchema.ArchivePeriod, num);
                }
            }
        }
 // Token: 0x06000423 RID: 1059 RVA: 0x0001D818 File Offset: 0x0001BA18
 private bool GetStoreData()
 {
     if (this.configItem == null)
     {
         this.EnsureUserConfigurationIsValid();
     }
     try
     {
         this.storeTagDictionary = MrmFaiFormatter.Deserialize(this.configItem, base.MailboxSession.MailboxOwner, out this.deletedTags, out this.fullCrawlRequired);
         if (this.IsArchiveMailUser)
         {
             foreach (StoreTagData storeTagData in this.storeTagDictionary.Values)
             {
                 bool flag = ElcMailboxHelper.IsArchiveTag(storeTagData, false);
                 if (storeTagData.Tag.Type == ElcFolderType.All && !flag)
                 {
                     foreach (ContentSetting contentSetting in storeTagData.ContentSettings.Values)
                     {
                         if (contentSetting.MessageClass.Equals(ElcMessageClass.AllMailboxContent, StringComparison.CurrentCultureIgnoreCase))
                         {
                             this.defaultAdTag = storeTagData.Tag.RetentionId;
                             break;
                         }
                         if (contentSetting.MessageClass.Equals(ElcMessageClass.VoiceMail, StringComparison.CurrentCultureIgnoreCase))
                         {
                             this.defaultVmAdTag = storeTagData.Tag.RetentionId;
                             break;
                         }
                     }
                 }
             }
             this.defaultContentSettingList = new List <ElcPolicySettings>();
             if (!this.defaultAdTag.Equals(Guid.Empty))
             {
                 foreach (ContentSetting elcContentSetting in this.storeTagDictionary[this.defaultAdTag].ContentSettings.Values)
                 {
                     ElcPolicySettings.ParseContentSettings(this.defaultContentSettingList, elcContentSetting);
                 }
             }
             if (!this.defaultVmAdTag.Equals(Guid.Empty))
             {
                 foreach (ContentSetting elcContentSetting2 in this.storeTagDictionary[this.defaultVmAdTag].ContentSettings.Values)
                 {
                     ElcPolicySettings.ParseContentSettings(this.defaultContentSettingList, elcContentSetting2);
                 }
             }
         }
     }
     catch (ObjectNotFoundException arg)
     {
         ElcUserInformation.Tracer.TraceDebug <ObjectNotFoundException>((long)this.GetHashCode(), "Deserialize of MRM FAI message failed because it could not be found. Exception: {0}", arg);
         return(false);
     }
     return(true);
 }
        // Token: 0x06000601 RID: 1537 RVA: 0x0002DB80 File Offset: 0x0002BD80
        protected override void CollectItemsToExpire()
        {
            int num = 0;

            if (base.MailboxDataForTags.HoldCleanupFolderType != DefaultFolderType.None)
            {
                HoldCleanupEnforcer.Tracer.TraceInformation <HoldCleanupEnforcer, DefaultFolderType, string>(32992, (long)this.GetHashCode(), "{0}: Resuming HoldCleanup at folder {1} and InternetMessageId {2}", this, base.MailboxDataForTags.HoldCleanupFolderType, base.MailboxDataForTags.HoldCleanupInternetMessageId);
                num = Array.IndexOf <DefaultFolderType>(HoldCleanupEnforcer.DumpsterFolders, base.MailboxDataForTags.HoldCleanupFolderType);
            }
            int num2 = num;

            try
            {
                for (int i = num; i < HoldCleanupEnforcer.DumpsterFolders.Length; i++)
                {
                    if (!this.CollectItemsInFolder(HoldCleanupEnforcer.DumpsterFolders[i]))
                    {
                        HoldCleanupEnforcer.Tracer.TraceWarning <HoldCleanupEnforcer, DefaultFolderType>((long)this.GetHashCode(), "{0}: CollectItemsToExpire did not complete for folderType {1}.", this, HoldCleanupEnforcer.DumpsterFolders[i]);
                        break;
                    }
                    num2++;
                }
            }
            finally
            {
                StringBuilder stringBuilder = new StringBuilder();
                IOrderedEnumerable <KeyValuePair <string, long> > source = from dirtyPropertyPair in this.dirtyPropertyCount
                                                                           orderby dirtyPropertyPair.Value descending
                                                                           select dirtyPropertyPair;
                foreach (KeyValuePair <string, long> keyValuePair in source.Take(10))
                {
                    stringBuilder.AppendFormat("{0}:  {1}", keyValuePair.Key, keyValuePair.Value);
                    stringBuilder.AppendLine();
                }
                Globals.Logger.LogEvent(base.MailboxDataForTags.ElcUserTagInformation.ADUser.OrganizationId, InfoWorkerEventLogConstants.Tuple_HoldCleanupStatistics, null, new object[]
                {
                    base.MailboxDataForTags.MailboxSession.MailboxOwner,
                    base.MailboxDataForTags.StatisticsLogEntry.NumberOfItemsAnalyzedByHoldCleanupEnforcer,
                    base.MailboxDataForTags.StatisticsLogEntry.NumberOfItemsDeterminedDuplicateByHoldCleanupEnforcer,
                    base.MailboxDataForTags.StatisticsLogEntry.SizeOfItemsDeterminedDuplicateByHoldCleanupEnforcer,
                    base.MailboxDataForTags.StatisticsLogEntry.NumberOfItemsSkippedByHoldCleanupEnforcer,
                    num2 == HoldCleanupEnforcer.DumpsterFolders.Length,
                    stringBuilder
                });
            }
            if (num2 == HoldCleanupEnforcer.DumpsterFolders.Length)
            {
                Exception arg = null;
                if (!ElcMailboxHelper.ClearHoldCleanupWatermarkFAIMessage(base.MailboxDataForTags.MailboxSession.ClientInfoString, base.MailboxDataForTags.MailboxSession.MailboxOwner, out arg))
                {
                    HoldCleanupEnforcer.Tracer.TraceError <HoldCleanupEnforcer, Exception>((long)this.GetHashCode(), "{0}: Unable to clear the watermark due to {1}.", this, arg);
                }
            }
        }
        // Token: 0x0600063F RID: 1599 RVA: 0x0002FC3C File Offset: 0x0002DE3C
        bool IAuditRecordStrategy <ItemData> .RecordFilter(IReadOnlyPropertyBag propertyBag, out bool stopNow)
        {
            stopNow = false;
            VersionedId versionedId = propertyBag[ItemSchema.Id] as VersionedId;

            if (versionedId == null)
            {
                if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.ErrorTrace))
                {
                    AuditExpirationEnforcer.Tracer.TraceError <AuditExpirationEnforcer>((long)this.GetHashCode(), "{0}: We could not get id of this item. Skipping it.", this);
                }
                return(false);
            }
            if (ElcGlobals.ExpireDumpsterRightNow)
            {
                return(true);
            }
            object obj = propertyBag[StoreObjectSchema.CreationTime];

            if (!ElcMailboxHelper.Exists(obj))
            {
                if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    AuditExpirationEnforcer.Tracer.TraceDebug <AuditExpirationEnforcer>((long)this.GetHashCode(), "{0}: CreationTime date is missing. Skipping the item.", this);
                }
                return(false);
            }
            DateTime dateTime = (DateTime)((ExDateTime)obj).ToUtc();

            if (dateTime > this.expirationTime)
            {
                if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    AuditExpirationEnforcer.Tracer.TraceDebug((long)this.GetHashCode(), "{0}: Item {1} newer than minAgeLimitForFolder. Item:{2}, Limit:{3}.", new object[]
                    {
                        this,
                        versionedId,
                        dateTime,
                        this.expirationTime
                    });
                }
                stopNow = true;
                return(false);
            }
            if (this.oldestExpiringLog.CompareTo(DateTime.MinValue) == 0)
            {
                this.oldestExpiringLog = dateTime;
            }
            else if (dateTime.CompareTo(this.oldestExpiringLog) < 0)
            {
                this.oldestExpiringLog = dateTime;
            }
            return(true);
        }
Exemple #14
0
        // Token: 0x060002D5 RID: 725 RVA: 0x000115C4 File Offset: 0x0000F7C4
        private void BuildListOfProvisionedFolders()
        {
            VersionedId rootFolderId = null;
            string      text         = null;

            using (Folder folder = Folder.Bind(this.MailboxSession, DefaultFolderType.Root, FolderProcessor.DataColumns))
            {
                rootFolderId = folder.Id;
                try
                {
                    if (ElcMailboxHelper.Exists(folder[FolderSchema.ELCPolicyIds]))
                    {
                        text = (string)folder[FolderSchema.ELCPolicyIds];
                        List <object> list = new List <object>(folder.GetProperties(FolderProcessor.DataColumns));
                        list.Add(list[3]);
                        this.entireFolderList.Add(list.ToArray());
                        FolderProcessor.Tracer.TraceDebug <FolderProcessor, string>((long)this.GetHashCode(), "{0}: Root Policy '{1}' is set for this mailbox.", this, text);
                    }
                }
                catch (PropertyErrorException ex)
                {
                    if (ex.PropertyErrors[0].PropertyErrorCode != PropertyErrorCode.NotFound)
                    {
                        throw;
                    }
                    FolderProcessor.Tracer.TraceDebug <FolderProcessor>((long)this.GetHashCode(), "{0}: Root Policy does not exist for this mailbox.", this);
                }
                using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.DeepTraversal, null, null, FolderProcessor.DataColumns))
                {
                    for (;;)
                    {
                        object[][] rows = queryResult.GetRows(100);
                        if (rows.Length <= 0)
                        {
                            break;
                        }
                        for (int i = 0; i < rows.Length; i++)
                        {
                            this.entireFolderList.Add(rows[i]);
                        }
                    }
                }
            }
            ElcMailboxHelper.PopulateFolderPathProperty(this.entireFolderList, new FolderPathIndices(3, 6, 0, 1, 7));
            for (int j = 0; j < this.entireFolderList.Count; j++)
            {
                ProvisionedFolder provisionedFolder = this.GetProvisionedFolder(j, rootFolderId, text);
                if (provisionedFolder != null)
                {
                    this.ProvisionedFolderList.Add(provisionedFolder);
                }
            }
            FolderProcessor.Tracer.TraceDebug <FolderProcessor, int>((long)this.GetHashCode(), "{0}: Number of folders found with policies for this mailbox is: {1}.", this, this.ProvisionedFolderList.Count);
        }
 // Token: 0x0600041F RID: 1055 RVA: 0x0001D65A File Offset: 0x0001B85A
 internal void EnsureUserConfigurationIsValid()
 {
     if (this.configItem == null)
     {
         this.configItem = ElcMailboxHelper.OpenFaiMessage(base.MailboxSession, "MRM", true);
         if (this.configItem == null)
         {
             throw new TransientMailboxException(Strings.descFAIAvailabilityCannotBeDetermined);
         }
     }
 }
        // Token: 0x06000296 RID: 662 RVA: 0x0000F884 File Offset: 0x0000DA84
        private DateTime GetStartDateFromCreationDate(object[] itemProperties)
        {
            DateTime result = DateTime.MinValue;

            if (ElcMailboxHelper.Exists(itemProperties[this.propertyIndexHolder.ReceivedTimeIndex]))
            {
                result = (DateTime)((ExDateTime)itemProperties[this.propertyIndexHolder.ReceivedTimeIndex]);
            }
            else if (ElcMailboxHelper.Exists(itemProperties[this.propertyIndexHolder.CreationTimeIndex]))
            {
                result = (DateTime)((ExDateTime)itemProperties[this.propertyIndexHolder.CreationTimeIndex]);
            }
            return(result);
        }
		private static void FetchRetentionPolcyTagDataFromXSO(StoreRetentionPolicyTagHelper srpth)
		{
			if (srpth.exchangePrincipal == null)
			{
				ExTraceGlobals.ELCTracer.TraceDebug(0L, "Cannot fetch retention policy tag data because Exchange principal is not available.");
				return;
			}
			srpth.mailboxSession = MailboxSession.OpenAsAdmin(srpth.exchangePrincipal, CultureInfo.InvariantCulture, "Client=Management;Action=Get-/Set-RetentionPolicyTag");
			srpth.configItem = ElcMailboxHelper.OpenFaiMessage(srpth.mailboxSession, "MRM", true);
			if (srpth.configItem != null)
			{
				srpth.TagData = MrmFaiFormatter.Deserialize(srpth.configItem, srpth.exchangePrincipal, out srpth.deletedTags, out srpth.retentionHoldData, true, out srpth.defaultArchiveTagData, out srpth.fullCrawlRequired);
				return;
			}
			srpth.TagData = new Dictionary<Guid, StoreTagData>();
		}
        // Token: 0x06000202 RID: 514 RVA: 0x0000D698 File Offset: 0x0000B898
        private void InitializeHoldCleanupWatermark()
        {
            ElcMailboxHelper.ConfigState configState;
            Exception ex;

            ElcMailboxHelper.TryGetHoldCleanupWatermarkInStore(this.mailboxSession.MailboxOwner, this.mailboxSession.ClientInfoString, out this.holdCleanupFolderType, out this.holdCleanupInternetMessageId, out configState, out ex);
            if (ex != null)
            {
                MailboxData.Tracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: Unable to retrieve the hold cleanup watermark for this mailbox.", this.mailboxSession.MailboxOwner);
                return;
            }
            if (configState != ElcMailboxHelper.ConfigState.Found || configState != ElcMailboxHelper.ConfigState.Empty)
            {
                MailboxData.Tracer.TraceDebug <IExchangePrincipal, ElcMailboxHelper.ConfigState>((long)this.GetHashCode(), "{0}: Unable to retrieve hold cleanup for this mailbox. ConfigState is {1}. No error encountered.", this.mailboxSession.MailboxOwner, configState);
            }
        }
 // Token: 0x06000291 RID: 657 RVA: 0x0000F150 File Offset: 0x0000D350
 private DateTime?GetCalStartDateFromView(object[] itemProperties)
 {
     if (this.folderType == DefaultFolderType.Calendar)
     {
         if (ElcMailboxHelper.Exists(itemProperties[this.propertyIndexHolder.CalendarTypeIndex]) && ElcMailboxHelper.Exists(itemProperties[this.propertyIndexHolder.EndDateIndex]) && (CalendarItemType)itemProperties[this.propertyIndexHolder.CalendarTypeIndex] == CalendarItemType.Single)
         {
             this.tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Using end date property in view to calculate start date of item in Folder: {1}.", TraceContext.Get(), this.folderDisplayName);
             return(new DateTime?((DateTime)((ExDateTime)itemProperties[this.propertyIndexHolder.EndDateIndex])));
         }
         if (!ElcMailboxHelper.Exists(itemProperties[this.propertyIndexHolder.CalendarTypeIndex]))
         {
             this.tracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: Calendar item in Folder: {1} is corrupt.", TraceContext.Get(), this.folderDisplayName);
             return(new DateTime?(ItemStartDateCalculator.startDateForCorruptItems));
         }
     }
     return(null);
 }
Exemple #20
0
        // Token: 0x0600044E RID: 1102 RVA: 0x0001EEE0 File Offset: 0x0001D0E0
        private Guid?GetArchiveGuid()
        {
            PropertySynchronizerBase.Tracer.TraceDebug <FolderPropertySynchronizer, string>((long)this.GetHashCode(), "{0}: Start searching parent archive tag for folder: {1}", this, base.FolderDisplayName);
            if (this.effectiveArchiveGuid != null)
            {
                return(this.effectiveArchiveGuid);
            }
            Guid guid  = Guid.Empty;
            int  i     = this.indexInTree - 1;
            int  index = this.indexInTree;

            while (i >= 0)
            {
                if (((VersionedId)this.entireFolderList[i][0]).ObjectId.Equals((StoreObjectId)this.entireFolderList[index][5]))
                {
                    guid = ElcMailboxHelper.GetGuidFromBytes(this.entireFolderList[i][7], new Guid?(Guid.Empty), false, base.FolderDisplayName).Value;
                    if (!(guid == Guid.Empty) && base.ElcUserTagInformation.ContainsTag(guid))
                    {
                        this.effectiveArchiveGuid = new Guid?(guid);
                        break;
                    }
                    index = i;
                }
                i--;
            }
            if (this.parentFolderIdToPropertyMap != null && (this.effectiveArchiveGuid == null || this.effectiveArchiveGuid.Value.Equals(Guid.Empty) || !base.ElcUserTagInformation.ContainsTag(this.effectiveArchiveGuid.Value)))
            {
                PropertySynchronizerBase.Tracer.TraceDebug <FolderPropertySynchronizer>((long)this.GetHashCode(), "{0}: Cannot find parent in the current folder list. Try to find parent in parentFolderIdToPropertyMap", this);
                StoreObjectId key = (StoreObjectId)this.entireFolderList[index][5];
                Synchronizer.FolderPropertySet folderPropertySet;
                while (this.parentFolderIdToPropertyMap.TryGetValue(key, out folderPropertySet))
                {
                    guid = ElcMailboxHelper.GetGuidFromBytes(folderPropertySet.ArchiveTagProperty, new Guid?(Guid.Empty), false, base.FolderDisplayName).Value;
                    if (!(guid == Guid.Empty) && base.ElcUserTagInformation.ContainsTag(guid))
                    {
                        PropertySynchronizerBase.Tracer.TraceDebug <FolderPropertySynchronizer>((long)this.GetHashCode(), "{0}: Find parent in parentFolderIdToPropertyMap. And it has intelligable archive GUID. Stop...", this);
                        this.effectiveArchiveGuid = new Guid?(guid);
                        break;
                    }
                    key = folderPropertySet.ParentFolderId;
                    PropertySynchronizerBase.Tracer.TraceDebug <FolderPropertySynchronizer>((long)this.GetHashCode(), "{0}: Find parent in parentFolderIdToPropertyMap. But it has no intelligable archive GUID. Continue...", this);
                }
            }
            return(this.effectiveArchiveGuid);
        }
Exemple #21
0
        // Token: 0x060002CD RID: 717 RVA: 0x00010E44 File Offset: 0x0000F044
        internal string GetFolderPathFromId(StoreObjectId folderId)
        {
            string result = null;

            foreach (object[] array in this.entireFolderList)
            {
                if (ElcMailboxHelper.Exists(array[0]))
                {
                    StoreObjectId objectId = ((VersionedId)array[0]).ObjectId;
                    if (objectId.Equals(folderId))
                    {
                        result = (ElcMailboxHelper.Exists(array[7]) ? ((string)array[7]) : null);
                        break;
                    }
                }
            }
            return(result);
        }
        // Token: 0x06000673 RID: 1651 RVA: 0x0003133C File Offset: 0x0002F53C
        private void ProcessFolderContents(Folder folder, ItemQueryType itemQueryType)
        {
            int num = base.FolderItemTypeCount(folder, itemQueryType);

            if (num <= 0)
            {
                CalendarLogExpirationEnforcer.Tracer.TraceDebug <CalendarLogExpirationEnforcer, string, ItemQueryType>((long)this.GetHashCode(), "{0}:{1} Folder is Empty of type {2}", this, folder.Id.ObjectId.ToHexEntryId(), itemQueryType);
                return;
            }
            using (QueryResult queryResult = folder.ItemQuery(itemQueryType, null, new SortBy[]
            {
                new SortBy(CalendarLogExpirationEnforcer.agePropertyDefinition, SortOrder.Ascending)
            }, CalendarLogExpirationEnforcer.PropertyColumns.PropertyDefinitions))
            {
                queryResult.SeekToOffset(SeekReference.OriginBeginning, 0);
                bool flag = false;
                while (!flag)
                {
                    object[][] rows = queryResult.GetRows(100);
                    if (rows.Length <= 0)
                    {
                        break;
                    }
                    foreach (object[] rawProperties in rows)
                    {
                        PropertyArrayProxy propertyArrayProxy = new PropertyArrayProxy(CalendarLogExpirationEnforcer.PropertyColumns, rawProperties);
                        if (!ElcMailboxHelper.Exists(propertyArrayProxy[CalendarLogExpirationEnforcer.agePropertyDefinition]))
                        {
                            CalendarLogExpirationEnforcer.Tracer.TraceDebug <CalendarLogExpirationEnforcer>((long)this.GetHashCode(), "{0}: Last Modified date is missing. Skipping items from here on.", this);
                            flag = true;
                            break;
                        }
                        if (!this.EnlistItem(propertyArrayProxy))
                        {
                            flag = true;
                            break;
                        }
                    }
                    base.SysCleanupSubAssistant.ThrottleStoreCallAndCheckForShutdown(base.MailboxDataForTags.MailboxSession.MailboxOwner);
                }
            }
        }
Exemple #23
0
 // Token: 0x0600043E RID: 1086 RVA: 0x0001DCBC File Offset: 0x0001BEBC
 internal FolderPropertySynchronizer(MailboxDataForTags mailboxDataForTags, ElcTagSubAssistant elcAssistant, Dictionary <StoreObjectId, Synchronizer.FolderPropertySet> parentFolderIdToPropertyMap, List <object[]> entireFolderList, int indexInTree) : base(mailboxDataForTags, elcAssistant)
 {
     this.entireFolderList            = entireFolderList;
     this.indexInTree                 = indexInTree;
     base.FolderProperties            = entireFolderList[indexInTree];
     this.parentFolderIdToPropertyMap = parentFolderIdToPropertyMap;
     this.originalTagGuid             = ElcMailboxHelper.GetGuidFromBytes(base.FolderProperties[2], new Guid?(Guid.Empty), true, base.FolderDisplayName).Value;
     this.originalRetentionFlags      = RetentionAndArchiveFlags.None;
     if (base.FolderProperties[3] is int)
     {
         this.originalRetentionFlags = (RetentionAndArchiveFlags)base.FolderProperties[3];
         this.explicitRetention      = FlagsMan.IsExplicitSet(this.originalRetentionFlags);
         this.explicitArchive        = FlagsMan.IsExplicitArchiveSet(this.originalRetentionFlags);
     }
     this.originalRetentionPeriod = -1;
     if (base.FolderProperties[4] is int)
     {
         this.originalRetentionPeriod = (int)base.FolderProperties[4];
     }
 }
Exemple #24
0
        // Token: 0x06000493 RID: 1171 RVA: 0x00021068 File Offset: 0x0001F268
        private Guid GetEffectiveParentTag(string messageClass)
        {
            Guid guid = ElcMailboxHelper.GetGuidFromBytes(base.FolderProperties[2], new Guid?(Guid.Empty), false, base.FolderDisplayName).Value;

            if (guid == Guid.Empty)
            {
                if (messageClass.StartsWith(ElcMessageClass.VoiceMail.TrimEnd(new char[]
                {
                    '*'
                }), StringComparison.OrdinalIgnoreCase) && !base.ElcUserTagInformation.DefaultVmAdTag.Equals(Guid.Empty))
                {
                    guid = base.ElcUserTagInformation.DefaultVmAdTag;
                }
                else
                {
                    guid = base.ElcUserTagInformation.DefaultAdTag;
                }
            }
            return(guid);
        }
Exemple #25
0
        private bool LogonArchive(ExchangePrincipal mailboxEP)
        {
            bool result;

            using (MailboxSession mailboxSession = MailboxSession.OpenAsSystemService(mailboxEP, CultureInfo.InvariantCulture, "Client=Monitoring;Action=Test-ArchiveConnectivity"))
            {
                if (mailboxSession != null)
                {
                    if (this.IncludeArchiveMRMConfiguration || !string.IsNullOrEmpty(this.MessageId))
                    {
                        UserConfiguration userConfiguration = ElcMailboxHelper.OpenFaiMessage(mailboxSession, "MRM", false);
                        if (userConfiguration != null)
                        {
                            using (Stream xmlStream = userConfiguration.GetXmlStream())
                            {
                                using (StreamReader streamReader = new StreamReader(xmlStream))
                                {
                                    this.archiveFAI = streamReader.ReadToEnd();
                                }
                                goto IL_80;
                            }
                        }
                        this.archiveFAI = "No FAI found in Archive Mailbox.";
IL_80:
                        this.archiveLastProcessedTime = this.ReadMailboxTableProperties(mailboxSession);
                        if (!string.IsNullOrEmpty(this.MessageId))
                        {
                            this.GetELCItemProperties(mailboxSession, this.MessageId);
                        }
                    }
                    result = true;
                }
                else
                {
                    result = false;
                }
            }
            return(result);
        }
        private string[] GetUniqueFolderName(MailboxSession mailboxStore, StoreId folderId, string[] suggestedNames)
        {
            List <string> subFolderNames = new List <string>();

            using (Folder folder = Folder.Bind(mailboxStore, folderId))
            {
                using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.None, null, null, new PropertyDefinition[]
                {
                    FolderSchema.DisplayName
                }))
                {
                    ElcMailboxHelper.ForeachQueryResult(queryResult, delegate(object[] rowProps, ref bool breakLoop)
                    {
                        if (SearchResultProcessor.PropertyExists(rowProps[0]))
                        {
                            subFolderNames.Add((string)rowProps[0]);
                        }
                    });
                }
            }
            string[] array = new string[suggestedNames.Length];
            for (int i = 0; i < suggestedNames.Length; i++)
            {
                string        folderName = suggestedNames[i];
                List <string> list       = (from x in subFolderNames
                                            where x.StartsWith(folderName, StringComparison.OrdinalIgnoreCase)
                                            select x).ToList <string>();
                for (int j = 0; j < list.Count + 1; j++)
                {
                    if (list.Find((string x) => x.Equals(folderName, StringComparison.OrdinalIgnoreCase)) == null)
                    {
                        break;
                    }
                    folderName = string.Format("{0}-{1}", suggestedNames[i], j + 1);
                }
                array[i] = folderName;
            }
            return(array);
        }
Exemple #27
0
 // Token: 0x060003A3 RID: 931 RVA: 0x00019A5C File Offset: 0x00017C5C
 private void LookForNewTagsInAD(TagChange tagChange)
 {
     foreach (Guid key in this.elcUserInfo.TagsInUserPolicy.Keys)
     {
         bool flag  = ElcMailboxHelper.IsArchiveTag(this.elcUserInfo.TagsInUserPolicy[key], false);
         bool flag2 = this.elcUserInfo.MailboxSession.MailboxOwner.MailboxInfo.IsArchive && flag;
         if (!this.elcUserInfo.StoreTagDictionary.ContainsKey(this.elcUserInfo.EffectiveGuidMapping[key]))
         {
             if (this.elcUserInfo.TagsInUserPolicy[key].Tag.Type == ElcFolderType.All && flag)
             {
                 ADChangeDetector.Tracer.TraceDebug <ADChangeDetector, string>((long)this.GetHashCode(), "{0}: LookForNewTagsInAD: Default MTA tag: {1}. Skip checks for this tag.", this, this.elcUserInfo.TagsInUserPolicy[key].Tag.Name);
             }
             else
             {
                 ADChangeDetector.Tracer.TraceDebug <ADChangeDetector, string, ElcFolderType>((long)this.GetHashCode(), "{0}: LookForNewTagsInAD: A new tag '{1}' of type {2} was found in AD.", this, this.elcUserInfo.TagsInUserPolicy[key].Tag.Name, this.elcUserInfo.TagsInUserPolicy[key].Tag.Type);
                 if (this.elcUserInfo.TagsInUserPolicy[key].Tag.Type != ElcFolderType.Personal)
                 {
                     tagChange.ChangeType |= ChangeType.Other;
                 }
                 this.elcUserInfo.StoreTagDictionary[this.elcUserInfo.EffectiveGuidMapping[key]] = new StoreTagData(this.elcUserInfo.TagsInUserPolicy[key]);
                 if (flag2)
                 {
                     ADChangeDetector.Tracer.TraceDebug <ADChangeDetector, string>((long)this.GetHashCode(), "{0}: LookForNewTagsInAD: MTA tag: {1} in the archive mbx. Set IsVisible to false.", this, this.elcUserInfo.TagsInUserPolicy[key].Tag.Name);
                     this.elcUserInfo.StoreTagDictionary[this.elcUserInfo.EffectiveGuidMapping[key]].IsVisible = false;
                 }
                 this.UpdateStoreContentSettings(this.elcUserInfo.EffectiveGuidMapping[key]);
             }
         }
         else
         {
             ADChangeDetector.Tracer.TraceDebug <ADChangeDetector, string, ElcFolderType>((long)this.GetHashCode(), "{0}: LookForNewTagsInAD: Tag '{1}' of type {2} exists in FAI.", this, this.elcUserInfo.TagsInUserPolicy[key].Tag.Name, this.elcUserInfo.TagsInUserPolicy[key].Tag.Type);
             if (this.elcUserInfo.TagsInUserPolicy[key].Tag.Type == ElcFolderType.Personal && !flag2)
             {
                 this.elcUserInfo.StoreTagDictionary[this.elcUserInfo.EffectiveGuidMapping[key]].IsVisible = true;
             }
         }
     }
 }
        private List <object[]> PopulateFolderRows(MailboxSession mailboxSession, ElcFolderType folderScope)
        {
            List <object[]> list = null;
            List <object[]> result;

            try
            {
                using (Folder rootFolder = GetMailboxFolderStatistics.GetRootFolder(mailboxSession, folderScope))
                {
                    if (rootFolder == null)
                    {
                        if (folderScope != ElcFolderType.ManagedCustomFolder)
                        {
                            base.WriteError(new MailboxFolderStatisticsException(this.Identity.ToString(), Strings.ErrorFailedToFindFolderInMailbox(folderScope.ToString())), ErrorCategory.ReadError, null);
                        }
                        else
                        {
                            base.WriteError(new MailboxFolderStatisticsException(this.Identity.ToString(), Strings.ErrorFailedToManagedFoldersInMailbox), ErrorCategory.ReadError, null);
                        }
                        result = list;
                    }
                    else
                    {
                        list = new List <object[]>();
                        if (folderScope != ElcFolderType.ManagedCustomFolder)
                        {
                            object[] array = new object[GetMailboxFolderStatistics.folderStatProps.Length];
                            array[1]  = rootFolder[GetMailboxFolderStatistics.folderStatProps[1]];
                            array[2]  = rootFolder[GetMailboxFolderStatistics.folderStatProps[2]];
                            array[4]  = rootFolder[GetMailboxFolderStatistics.folderStatProps[4]];
                            array[5]  = rootFolder[GetMailboxFolderStatistics.folderStatProps[5]];
                            array[6]  = rootFolder.TryGetProperty(GetMailboxFolderStatistics.folderStatProps[6]);
                            array[0]  = rootFolder.TryGetProperty(GetMailboxFolderStatistics.folderStatProps[0]);
                            array[7]  = rootFolder.TryGetProperty(FolderSchema.AdminFolderFlags);
                            array[9]  = rootFolder.TryGetProperty(StoreObjectSchema.ParentItemId);
                            array[8]  = rootFolder.TryGetProperty(FolderSchema.ELCPolicyIds);
                            array[13] = rootFolder.TryGetProperty(StoreObjectSchema.PolicyTag);
                            array[14] = rootFolder.TryGetProperty(StoreObjectSchema.ArchiveTag);
                            array[11] = rootFolder.TryGetProperty(GetMailboxFolderStatistics.folderStatProps[11]);
                            array[12] = rootFolder.TryGetProperty(GetMailboxFolderStatistics.folderStatProps[12]);
                            array[3]  = 0;
                            array[10] = rootFolder.TryGetProperty(StoreObjectSchema.CreationTime);
                            list.Add(array);
                        }
                        GetMailboxFolderStatistics.GetFolderHierarchy(rootFolder, list);
                        if (folderScope == ElcFolderType.All)
                        {
                            using (Folder rootFolder2 = GetMailboxFolderStatistics.GetRootFolder(mailboxSession, ElcFolderType.RecoverableItems))
                            {
                                if (rootFolder2 != null)
                                {
                                    object[] array2 = new object[GetMailboxFolderStatistics.folderStatProps.Length];
                                    array2[1]  = rootFolder2[GetMailboxFolderStatistics.folderStatProps[1]];
                                    array2[2]  = rootFolder2[GetMailboxFolderStatistics.folderStatProps[2]];
                                    array2[4]  = rootFolder2[GetMailboxFolderStatistics.folderStatProps[4]];
                                    array2[5]  = rootFolder2[GetMailboxFolderStatistics.folderStatProps[5]];
                                    array2[6]  = rootFolder2.TryGetProperty(GetMailboxFolderStatistics.folderStatProps[6]);
                                    array2[0]  = rootFolder2.TryGetProperty(GetMailboxFolderStatistics.folderStatProps[0]);
                                    array2[7]  = rootFolder2.TryGetProperty(FolderSchema.AdminFolderFlags);
                                    array2[9]  = rootFolder2.TryGetProperty(StoreObjectSchema.ParentItemId);
                                    array2[8]  = rootFolder2.TryGetProperty(FolderSchema.ELCPolicyIds);
                                    array2[13] = rootFolder2.TryGetProperty(StoreObjectSchema.PolicyTag);
                                    array2[14] = rootFolder2.TryGetProperty(StoreObjectSchema.ArchiveTag);
                                    array2[11] = rootFolder2.TryGetProperty(GetMailboxFolderStatistics.folderStatProps[11]);
                                    array2[12] = rootFolder2.TryGetProperty(GetMailboxFolderStatistics.folderStatProps[12]);
                                    array2[3]  = 0;
                                    array2[10] = rootFolder2.TryGetProperty(StoreObjectSchema.CreationTime);
                                    list.Add(array2);
                                    GetMailboxFolderStatistics.GetFolderHierarchy(rootFolder2, list);
                                }
                            }
                        }
                        ElcMailboxHelper.PopulateFolderPathProperty(list, new FolderPathIndices(0, 3, 1, 9, 15));
                        result = list;
                    }
                }
            }
            catch (ObjectNotFoundException)
            {
                base.WriteError(new MailboxFolderStatisticsException(this.Identity.ToString(), Strings.ErrorFailedToFindFolderInMailbox(folderScope.ToString())), ErrorCategory.ReadError, null);
                result = null;
            }
            return(result);
        }
Exemple #29
0
		protected override void InternalProcessRecord()
		{
			TaskLogger.LogEnter(new object[]
			{
				this.DataObject
			});
			bool flag = false;
			if (false == this.Force && this.Arbitration)
			{
				TIdentity identity = this.Identity;
				if (!base.ShouldContinue(Strings.SetArbitrationMailboxConfirmationMessage(identity.ToString())))
				{
					TaskLogger.LogExit();
					return;
				}
			}
			if (false == this.Force && this.originalForwardingAddress == null && this.DataObject.ForwardingAddress != null && this.DataObject.ForwardingSmtpAddress != null)
			{
				LocalizedString message = (this.originalForwardingSmtpAddress != null) ? Strings.SetMailboxForwardingAddressConfirmationMessage : Strings.SetBothForwardingAddressConfirmationMessage;
				if (!base.ShouldContinue(message))
				{
					TaskLogger.LogExit();
					return;
				}
			}
			if (this.DataObject.IsModified(MailboxSchema.ForwardingSmtpAddress) && this.DataObject.ForwardingSmtpAddress != null && this.DataObject.ForwardingAddress != null && !base.Fields.IsModified(MailboxSchema.ForwardingAddress))
			{
				this.WriteWarning(Strings.ContactAdminForForwardingWarning);
			}
			if (false == this.Force && this.DataObject.IsModified(ADRecipientSchema.AuditLogAgeLimit))
			{
				EnhancedTimeSpan t;
				if (this.DataObject.MailboxAuditLogAgeLimit == EnhancedTimeSpan.Zero)
				{
					TIdentity identity2 = this.Identity;
					if (!base.ShouldContinue(Strings.ConfirmationMessageSetMailboxAuditLogAgeLimitZero(identity2.ToString())))
					{
						TaskLogger.LogExit();
						return;
					}
				}
				else if (this.DataObject.TryGetOriginalValue<EnhancedTimeSpan>(ADRecipientSchema.AuditLogAgeLimit, out t))
				{
					EnhancedTimeSpan mailboxAuditLogAgeLimit = this.DataObject.MailboxAuditLogAgeLimit;
					if (t > mailboxAuditLogAgeLimit)
					{
						TIdentity identity3 = this.Identity;
						if (!base.ShouldContinue(Strings.ConfirmationMessageSetMailboxAuditLogAgeLimitSmaller(identity3.ToString(), mailboxAuditLogAgeLimit.ToString())))
						{
							TaskLogger.LogExit();
							return;
						}
					}
				}
			}
			bool flag2 = false;
			bool flag3 = false;
			MapiMessageStoreSession mapiMessageStoreSession = null;
			try
			{
				if (this.needChangeMailboxSubtype)
				{
					if (this.originalRecipientTypeDetails == RecipientTypeDetails.UserMailbox)
					{
						MailboxTaskHelper.GrantPermissionToLinkedUserAccount(this.DataObject, PermissionTaskHelper.GetReadOnlySession(null), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
						flag2 = true;
						flag3 = true;
					}
					else if (this.targetRecipientTypeDetails == RecipientTypeDetails.UserMailbox)
					{
						MailboxTaskHelper.ClearExternalAssociatedAccountPermission(this.DataObject, PermissionTaskHelper.GetReadOnlySession(null), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
						flag = true;
						flag3 = true;
					}
				}
				else if (this.DataObject.IsChanged(ADRecipientSchema.MasterAccountSid))
				{
					MailboxTaskHelper.GrantPermissionToLinkedUserAccount(this.DataObject, PermissionTaskHelper.GetReadOnlySession(null), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
					flag2 = true;
					flag3 = true;
				}
				base.InternalProcessRecord();
				if (flag3)
				{
					PermissionTaskHelper.SaveMailboxSecurityDescriptor(this.DataObject, SecurityDescriptorConverter.ConvertToActiveDirectorySecurity(this.DataObject.ExchangeSecurityDescriptor), (IRecipientSession)base.DataSession, ref mapiMessageStoreSession, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
				}
			}
			finally
			{
				if (mapiMessageStoreSession != null)
				{
					mapiMessageStoreSession.Dispose();
				}
			}
			if (flag2)
			{
				base.WriteVerbose(Strings.VerboseSaveADSecurityDescriptor(this.DataObject.Id.ToString()));
				this.DataObject.SaveSecurityDescriptor(((SecurityDescriptor)this.DataObject[ADObjectSchema.NTSecurityDescriptor]).ToRawSecurityDescriptor());
			}
			bool flag4 = base.Fields.IsModified(ADUserSchema.SharingPolicy);
			if (this.RemoveManagedFolderAndPolicy || flag || flag4)
			{
				ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, false);
				IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.IgnoreInvalid, sessionSettings, 4021, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\mailbox\\SetMailbox.cs");
				if (!tenantOrRootOrgRecipientSession.IsReadConnectionAvailable())
				{
					tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 4030, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\mailbox\\SetMailbox.cs");
				}
				MailboxSession mailboxSession = this.OpenMailboxSession(tenantOrRootOrgRecipientSession, this.DataObject);
				if (mailboxSession == null)
				{
					base.WriteError(new RecipientTaskException(Strings.LogonFailure), ExchangeErrorCategory.ServerOperation, null);
					return;
				}
				using (mailboxSession)
				{
					if (this.RemoveManagedFolderAndPolicy && !ElcMailboxHelper.RemoveElcInMailbox(mailboxSession))
					{
						this.WriteWarning(Strings.WarningNonemptyManagedFolderNotDeleted);
					}
					if (flag)
					{
						using (CalendarConfigurationDataProvider calendarConfigurationDataProvider = new CalendarConfigurationDataProvider(mailboxSession))
						{
							CalendarConfiguration calendarConfiguration = (CalendarConfiguration)calendarConfigurationDataProvider.Read<CalendarConfiguration>(null);
							calendarConfiguration.AutomateProcessing = CalendarProcessingFlags.None;
							try
							{
								calendarConfigurationDataProvider.Save(calendarConfiguration);
							}
							catch (LocalizedException exception)
							{
								base.WriteError(exception, ExchangeErrorCategory.ServerOperation, null);
							}
						}
					}
					if (flag4)
					{
						mailboxSession.Mailbox.Delete(MailboxSchema.LastSharingPolicyAppliedId);
						mailboxSession.Mailbox.Delete(MailboxSchema.LastSharingPolicyAppliedHash);
						mailboxSession.Mailbox.Delete(MailboxSchema.LastSharingPolicyAppliedTime);
						mailboxSession.Mailbox.Save();
					}
				}
			}
			if (base.IsSetRandomPassword)
			{
				MailboxTaskHelper.SetMailboxPassword((IRecipientSession)base.DataSession, this.DataObject, null, new Task.ErrorLoggerDelegate(base.WriteError));
			}
			TaskLogger.LogExit();
		}
Exemple #30
0
        // Token: 0x060002D6 RID: 726 RVA: 0x00011780 File Offset: 0x0000F980
        private ProvisionedFolder GetProvisionedFolder(int currFolderIdx, VersionedId rootFolderId, string rootFolderPolicyIds)
        {
            bool flag = false;

            if (!ElcMailboxHelper.Exists(this.entireFolderList[currFolderIdx][2]))
            {
                flag = true;
                FolderProcessor.Tracer.TraceDebug <FolderProcessor, object>((long)this.GetHashCode(), "{0}: Folder '{1}' does not have any policy associated. Checking parent and root.", this, this.entireFolderList[currFolderIdx][3]);
                object obj = this.entireFolderList[currFolderIdx][1];
                int    num = currFolderIdx;
                while (ElcMailboxHelper.Exists(obj) && !((StoreObjectId)obj).Equals(rootFolderId.ObjectId))
                {
                    int num2 = -1;
                    int num3 = (num == 0) ? (this.entireFolderList.Count - 1) : (num - 1);
                    while (num3 != num)
                    {
                        VersionedId versionedId = (VersionedId)this.entireFolderList[num3][0];
                        if (versionedId.ObjectId.Equals((StoreObjectId)obj))
                        {
                            num2 = num3;
                            break;
                        }
                        if (num3 == 0)
                        {
                            num3 = this.entireFolderList.Count - 1;
                        }
                        else
                        {
                            num3--;
                        }
                    }
                    if (num2 == -1)
                    {
                        throw new SkipException(Strings.descMissingParentFolder(this.entireFolderList[num][3], obj));
                    }
                    if (ElcMailboxHelper.Exists(this.entireFolderList[num2][2]))
                    {
                        FolderProcessor.Tracer.TraceDebug <FolderProcessor, object, object>((long)this.GetHashCode(), "{0}: Parent folder '{1}' of folder '{2}' has policy. Assigning to child.", this, this.entireFolderList[num2][3], this.entireFolderList[currFolderIdx][3]);
                        this.entireFolderList[currFolderIdx][2] = this.entireFolderList[num2][2];
                        break;
                    }
                    obj = this.entireFolderList[num2][1];
                    num = num2;
                }
                if (!ElcMailboxHelper.Exists(this.entireFolderList[currFolderIdx][2]) && !string.IsNullOrEmpty(rootFolderPolicyIds))
                {
                    FolderProcessor.Tracer.TraceDebug <FolderProcessor, object>((long)this.GetHashCode(), "{0}: Folder '{1}' takes on root policy.", this, this.entireFolderList[currFolderIdx][3]);
                    this.entireFolderList[currFolderIdx][2] = rootFolderPolicyIds;
                }
            }
            if (!ElcMailboxHelper.Exists(this.entireFolderList[currFolderIdx][2]))
            {
                FolderProcessor.Tracer.TraceDebug <FolderProcessor, object>((long)this.GetHashCode(), "{0}: Folder '{1}' being discarded because it does not have an associated folder object.", this, this.entireFolderList[currFolderIdx][3]);
                return(null);
            }
            string       displayName        = (string)this.entireFolderList[currFolderIdx][3];
            AdFolderData folderDataFromList = this.GetFolderDataFromList((string)this.entireFolderList[currFolderIdx][2]);

            if (folderDataFromList.Folder.BaseFolderOnly && flag)
            {
                if (string.IsNullOrEmpty(rootFolderPolicyIds) || !((string)this.entireFolderList[currFolderIdx][2] != rootFolderPolicyIds))
                {
                    FolderProcessor.Tracer.TraceDebug <FolderProcessor, object>((long)this.GetHashCode(), "{0}: Folder '{1}' being discarded because it does not inherit policy and not root policy is defined..", this, this.entireFolderList[currFolderIdx][3]);
                    return(null);
                }
                FolderProcessor.Tracer.TraceDebug <FolderProcessor, object>((long)this.GetHashCode(), "{0}: Folder '{1}' takes on root policy.", this, this.entireFolderList[currFolderIdx][3]);
                this.entireFolderList[currFolderIdx][2] = rootFolderPolicyIds;
                folderDataFromList = this.GetFolderDataFromList((string)this.entireFolderList[currFolderIdx][2]);
            }
            VersionedId versionedId2        = (VersionedId)this.entireFolderList[currFolderIdx][0];
            bool        isProvisionedFolder = ElcMailboxHelper.Exists(this.entireFolderList[currFolderIdx][4]) && ((int)this.entireFolderList[currFolderIdx][4] & 1) != 0;
            string      containerClass      = null;

            if (ElcMailboxHelper.Exists(this.entireFolderList[currFolderIdx][5]))
            {
                containerClass = (string)this.entireFolderList[currFolderIdx][5];
            }
            string fullFolderPath = string.Empty;

            if (ElcMailboxHelper.Exists(this.entireFolderList[currFolderIdx][7]))
            {
                fullFolderPath = HttpUtility.UrlDecode((string)this.entireFolderList[currFolderIdx][7]);
            }
            if (folderDataFromList == null || folderDataFromList.FolderSettings == null)
            {
                FolderProcessor.Tracer.TraceDebug <FolderProcessor, object>((long)this.GetHashCode(), "{0}: Folder '{1}' has an associated ElcFolder object, but no policy applies to it.", this, this.entireFolderList[currFolderIdx][3]);
            }
            return(new ProvisionedFolder(versionedId2.ObjectId, displayName, fullFolderPath, containerClass, isProvisionedFolder, folderDataFromList.FolderSettings, new Guid((string)this.entireFolderList[currFolderIdx][2]), flag));
        }