예제 #1
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));
        }
예제 #2
0
        // Token: 0x06000193 RID: 403 RVA: 0x0000BB44 File Offset: 0x00009D44
        private void GetLegacyStateAndSetLitigationHoldDuration()
        {
            ElcMailboxHelper.ConfigState configState = ElcMailboxHelper.ConfigState.Unknown;
            IRecipientSession            recipientSession;
            ADUser aduser = AdReader.GetADUser(this.mailboxSession, false, out recipientSession);

            if (aduser == null)
            {
                ElcUserInformation.Tracer.TraceError((long)this.GetHashCode(), "{0}: Failed to get the writable AD information for the user.", new object[]
                {
                    TraceContext.Get()
                });
                throw new SkipException(Strings.descADUserLookupFailure(this.mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString()));
            }
            Unlimited <EnhancedTimeSpan>?legacyLitigationHoldDuration = this.GetLegacyLitigationHoldDuration(out configState);

            aduser.LitigationHoldDuration = legacyLitigationHoldDuration;
            try
            {
                recipientSession.Save(aduser);
            }
            catch (DataValidationException ex)
            {
                ElcUserInformation.Tracer.TraceDebug <ElcUserInformation, string, DataValidationException>((long)this.GetHashCode(), "{0}: DataValidationException occurred when setting LitigationHoldDuration to ADUser. Duration value: {1}. Exception: {2}", this, (legacyLitigationHoldDuration != null) ? (legacyLitigationHoldDuration.Value.IsUnlimited ? Unlimited <EnhancedTimeSpan> .UnlimitedString : legacyLitigationHoldDuration.Value.Value.TotalDays.ToString()) : "No value", ex);
                throw new SkipException(new LocalizedString(string.Format("{0}: DataValidationException occurred when setting LitigationHoldDuration to ADUser. Duration value: {1}.", this, (legacyLitigationHoldDuration != null) ? (legacyLitigationHoldDuration.Value.IsUnlimited ? Unlimited <EnhancedTimeSpan> .UnlimitedString : legacyLitigationHoldDuration.Value.Value.TotalDays.ToString()) : "No value")), ex);
            }
            this.litigationHoldDuration = aduser.LitigationHoldDuration;
        }
예제 #3
0
 internal static void TryGetExistingValueInStore <T>(IExchangePrincipal exchangePrincipal, string clientString, string userConfigKey, Func <string, KeyValuePair <T, ElcMailboxHelper.ConfigState> > valueFunction, out T existingValue, out ElcMailboxHelper.ConfigState state, out Exception exception)
 {
     existingValue = default(T);
     state         = ElcMailboxHelper.ConfigState.Unknown;
     exception     = null;
     try
     {
         using (MailboxSession mailboxSession = ElcMailboxHelper.OpenMailboxSessionAsSystemService(exchangePrincipal, clientString))
         {
             if (mailboxSession == null)
             {
                 state = ElcMailboxHelper.ConfigState.ErrorWhileFetching;
             }
             else
             {
                 StoreId systemFolderId = mailboxSession.GetSystemFolderId();
                 if (systemFolderId != null)
                 {
                     using (UserConfiguration userConfiguration = ElcMailboxHelper.OpenFaiMessage(mailboxSession, "MRM", false, systemFolderId))
                     {
                         if (userConfiguration == null)
                         {
                             state = ElcMailboxHelper.ConfigState.FAINotFound;
                         }
                         else
                         {
                             IDictionary dictionary = userConfiguration.GetDictionary();
                             if (dictionary != null && dictionary.Contains(userConfigKey))
                             {
                                 string text = dictionary[userConfigKey] as string;
                                 if (text != null)
                                 {
                                     KeyValuePair <T, ElcMailboxHelper.ConfigState> keyValuePair = valueFunction(text);
                                     existingValue = keyValuePair.Key;
                                     state         = keyValuePair.Value;
                                 }
                                 else
                                 {
                                     state = ElcMailboxHelper.ConfigState.Empty;
                                 }
                             }
                             else
                             {
                                 state = ElcMailboxHelper.ConfigState.Empty;
                             }
                         }
                         goto IL_AE;
                     }
                 }
                 state = ElcMailboxHelper.ConfigState.FAINotFound;
             }
             IL_AE :;
         }
     }
     catch (InvalidCastException ex)
     {
         state     = ElcMailboxHelper.ConfigState.Corrupt;
         exception = ex;
     }
     catch (CorruptDataException ex2)
     {
         state     = ElcMailboxHelper.ConfigState.Corrupt;
         exception = ex2;
     }
     catch (InvalidOperationException ex3)
     {
         state     = ElcMailboxHelper.ConfigState.Invalid;
         exception = ex3;
     }
     catch (StorageTransientException ex4)
     {
         state     = ElcMailboxHelper.ConfigState.ErrorWhileFetching;
         exception = ex4;
     }
     catch (StoragePermanentException ex5)
     {
         state     = ElcMailboxHelper.ConfigState.ErrorWhileFetching;
         exception = ex5;
     }
 }
예제 #4
0
        internal static void TryGetEHAHiddenFolderCleanupWatermarkInStore(IExchangePrincipal exchangePrincipal, string clientString, out ElcMailboxHelper.ConfigState state, out Exception exception)
        {
            Func <string, KeyValuePair <string, ElcMailboxHelper.ConfigState> > valueFunction = delegate(string value)
            {
                ElcMailboxHelper.ConfigState value2;
                if (!string.IsNullOrEmpty(value))
                {
                    if (!value.Equals("EHAHiddenFolderCleanupWatermark"))
                    {
                        value2 = ElcMailboxHelper.ConfigState.Invalid;
                    }
                    else
                    {
                        value2 = ElcMailboxHelper.ConfigState.Found;
                    }
                }
                else
                {
                    value2 = ElcMailboxHelper.ConfigState.Empty;
                }
                return(new KeyValuePair <string, ElcMailboxHelper.ConfigState>(value, value2));
            };
            string text = null;

            ElcMailboxHelper.TryGetExistingValueInStore <string>(exchangePrincipal, clientString, "EHAHiddenFolderCleanupWatermark", valueFunction, out text, out state, out exception);
        }
예제 #5
0
        internal static void TryGetHoldCleanupWatermarkInStore(IExchangePrincipal exchangePrincipal, string clientString, out DefaultFolderType folderType, out string internetMessageId, out ElcMailboxHelper.ConfigState state, out Exception exception)
        {
            folderType        = DefaultFolderType.None;
            internetMessageId = null;
            Func <string, KeyValuePair <string, ElcMailboxHelper.ConfigState> > valueFunction = delegate(string value)
            {
                ElcMailboxHelper.ConfigState value2;
                if (!string.IsNullOrEmpty(value))
                {
                    value2 = ElcMailboxHelper.ConfigState.Found;
                }
                else
                {
                    value2 = ElcMailboxHelper.ConfigState.Empty;
                }
                return(new KeyValuePair <string, ElcMailboxHelper.ConfigState>(value, value2));
            };
            string text = null;

            ElcMailboxHelper.TryGetExistingValueInStore <string>(exchangePrincipal, clientString, "HoldCleanupWatermark", valueFunction, out text, out state, out exception);
            if (state == ElcMailboxHelper.ConfigState.Found)
            {
                string[] array = text.Split(new char[]
                {
                    ':'
                }, 2);
                try
                {
                    folderType = (DefaultFolderType)Enum.Parse(typeof(DefaultFolderType), array[0]);
                    if (array.Length == 2)
                    {
                        internetMessageId = array[1];
                    }
                }
                catch (ArgumentException)
                {
                    state = ElcMailboxHelper.ConfigState.Corrupt;
                }
            }
        }
예제 #6
0
        internal static void TryGetExistingHoldDurationInStore(IExchangePrincipal exchangePrincipal, string clientString, out Unlimited <EnhancedTimeSpan> existingHoldDuration, out ElcMailboxHelper.ConfigState state, out Exception exception)
        {
            Func <string, KeyValuePair <Unlimited <EnhancedTimeSpan>, ElcMailboxHelper.ConfigState> > valueFunction = delegate(string value)
            {
                Unlimited <EnhancedTimeSpan> key = default(Unlimited <EnhancedTimeSpan>);
                ElcMailboxHelper.ConfigState value2;
                double value3;
                if (string.Compare(value, Globals.UnlimitedHoldDuration, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    key    = Unlimited <EnhancedTimeSpan> .UnlimitedValue;
                    value2 = ElcMailboxHelper.ConfigState.Found;
                }
                else if (double.TryParse(value.ToString(), out value3))
                {
                    EnhancedTimeSpan fromValue = EnhancedTimeSpan.FromMilliseconds(value3);
                    key    = fromValue;
                    value2 = ElcMailboxHelper.ConfigState.Found;
                }
                else
                {
                    value2 = ElcMailboxHelper.ConfigState.Corrupt;
                }
                return(new KeyValuePair <Unlimited <EnhancedTimeSpan>, ElcMailboxHelper.ConfigState>(key, value2));
            };

            ElcMailboxHelper.TryGetExistingValueInStore <Unlimited <EnhancedTimeSpan> >(exchangePrincipal, clientString, "LitigationHoldDuration", valueFunction, out existingHoldDuration, out state, out exception);
        }