Example #1
0
        protected static bool TryGetDelegateRuleTypeFromSession(MailboxSession session, out DelegateRuleType?ruleType)
        {
            bool result = false;

            ruleType = null;
            if (session != null && session.Capabilities.CanHaveDelegateUsers)
            {
                try
                {
                    DelegateUserCollection delegateUserCollection = new DelegateUserCollection(session);
                    if (delegateUserCollection.Count > 0)
                    {
                        ruleType = new DelegateRuleType?(delegateUserCollection.DelegateRuleType);
                    }
                    result = true;
                }
                catch (DelegateUserNoFreeBusyFolderException)
                {
                    ExTraceGlobals.MeetingMessageTracer.Information((long)session.GetHashCode(), "Storage.MeetingMessage.TryGetDelegateType: NoFreeBusyData Folder, failing to get delegate rule type.");
                }
                catch (ObjectNotFoundException)
                {
                    ExTraceGlobals.MeetingMessageTracer.Information((long)session.GetHashCode(), "Storage.MeetingMessage.TryGetDelegateType: No delegates found, failing to get delegate rule type.");
                }
            }
            return(result);
        }
        // Token: 0x06000B7A RID: 2938 RVA: 0x0004A418 File Offset: 0x00048618
        private static bool InternalCheckForAutomaticBooking(bool isEventForConfigObject, MailboxSession itemStore, CachedState cachedState)
        {
            cachedState.LockForRead();
            CalendarConfiguration calendarConfiguration;

            try
            {
                calendarConfiguration = (cachedState.State[0] as CalendarConfiguration);
                if (calendarConfiguration == null || isEventForConfigObject)
                {
                    LockCookie lockCookie = cachedState.UpgradeToWriterLock();
                    try
                    {
                        using (CalendarConfigurationDataProvider calendarConfigurationDataProvider = new CalendarConfigurationDataProvider(itemStore))
                        {
                            calendarConfiguration = (CalendarConfiguration)calendarConfigurationDataProvider.Read <CalendarConfiguration>(null);
                            if (calendarConfiguration == null)
                            {
                                Globals.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_CorruptCalendarConfiguration, null, new object[]
                                {
                                    itemStore.MailboxOwner.LegacyDn
                                });
                                calendarConfigurationDataProvider.Delete(new CalendarConfiguration());
                                calendarConfiguration = new CalendarConfiguration();
                            }
                        }
                        if (calendarConfiguration.AutomateProcessing == CalendarProcessingFlags.AutoAccept)
                        {
                            calendarConfiguration.AddNewRequestsTentatively = true;
                        }
                        cachedState.State[0] = calendarConfiguration;
                        ResourceCheck.Tracer.TraceDebug((long)itemStore.GetHashCode(), "{0}: The calendar settings object was new or has been changed - (re)reading contents.", new object[]
                        {
                            TraceContext.Get()
                        });
                    }
                    catch (ObjectNotFoundException innerException)
                    {
                        ResourceCheck.Tracer.TraceError((long)itemStore.GetHashCode(), "{0}: The calendar configuration was deleted while we were looking at it. Back off and retry.", new object[]
                        {
                            TraceContext.Get()
                        });
                        throw new TransientMailboxException(innerException);
                    }
                    finally
                    {
                        cachedState.DowngradeFromWriterLock(ref lockCookie);
                    }
                }
            }
            finally
            {
                cachedState.ReleaseReaderLock();
            }
            ResourceCheck.Tracer.TraceDebug <object, CalendarProcessingFlags>((long)itemStore.GetHashCode(), "{0}: MailboxType {1}", TraceContext.Get(), calendarConfiguration.AutomateProcessing);
            ResourceCheck.TracerPfd.TracePfd <int, object, CalendarProcessingFlags>((long)itemStore.GetHashCode(), "PFD IWR {0} {1}: ResourceMailbox: {2}", 19223, TraceContext.Get(), calendarConfiguration.AutomateProcessing);
            return(calendarConfiguration.AutomateProcessing == CalendarProcessingFlags.AutoAccept);
        }
        // Token: 0x06000464 RID: 1124 RVA: 0x0001F97C File Offset: 0x0001DB7C
        internal static Dictionary <StoreObjectId, FolderTuple> QueryFolderHierarchy(MailboxSession mailboxSession)
        {
            Dictionary <StoreObjectId, FolderTuple> dictionary = new Dictionary <StoreObjectId, FolderTuple>();

            if (mailboxSession == null)
            {
                return(dictionary);
            }
            FolderHelper.Tracer.TraceDebug <IExchangePrincipal, bool>((long)mailboxSession.GetHashCode(), "{0}: QueryFolderHierarchy: Archive mailbox: {1}.", mailboxSession.MailboxOwner, mailboxSession.MailboxOwner.MailboxInfo.IsArchive);
            StoreObjectId defaultFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.Root);

            dictionary[defaultFolderId] = new FolderTuple(defaultFolderId, defaultFolderId, string.Empty, new object[10], true);
            using (Folder folder = Folder.Bind(mailboxSession, defaultFolderId))
            {
                using (QueryResult queryResult = folder.FolderQuery(FolderQueryFlags.DeepTraversal, null, null, FolderHelper.DataColumns))
                {
                    for (;;)
                    {
                        object[][] rows = queryResult.GetRows(100);
                        if (rows.Length <= 0)
                        {
                            break;
                        }
                        for (int i = 0; i < rows.Length; i++)
                        {
                            if (rows[i][0] is VersionedId && rows[i][1] is StoreObjectId)
                            {
                                StoreObjectId objectId      = (rows[i][0] as VersionedId).ObjectId;
                                StoreObjectId storeObjectId = rows[i][1] as StoreObjectId;
                                dictionary[objectId] = new FolderTuple(objectId, storeObjectId, (string)rows[i][2], rows[i]);
                                FolderHelper.Tracer.TraceDebug((long)mailboxSession.GetHashCode(), "{0}: QueryFolderHierarchy: Added folder '{1}' to the folderMap. FolderId: '{2}'. ParentId: '{3}'.", new object[]
                                {
                                    mailboxSession.MailboxOwner,
                                    (string)rows[i][2],
                                    objectId.ToHexEntryId(),
                                    storeObjectId.ToHexEntryId()
                                });
                            }
                        }
                    }
                }
            }
            return(dictionary);
        }
Example #4
0
        // Token: 0x060004EE RID: 1262 RVA: 0x00025828 File Offset: 0x00023A28
        internal static UserRetentionPolicyCache DetailedCheckForRetentionPolicy(MapiEvent mapiEvent, MailboxSession itemStore, StoreObject item, CachedState cachedState)
        {
            UserRetentionPolicyCache userRetentionPolicyCache = null;

            cachedState.LockForRead();
            try
            {
                userRetentionPolicyCache = (cachedState.State[5] as UserRetentionPolicyCache);
                if (userRetentionPolicyCache == null || (item != null && RetentionPolicyCheck.IsEventConfigChange(mapiEvent)) || (userRetentionPolicyCache.HasPendingFaiEvent && userRetentionPolicyCache.PendingFaiEventCounter <= mapiEvent.EventCounter))
                {
                    LockCookie lockCookie = cachedState.UpgradeToWriterLock();
                    try
                    {
                        if (userRetentionPolicyCache == null || !userRetentionPolicyCache.UnderRetentionPolicy)
                        {
                            userRetentionPolicyCache = new UserRetentionPolicyCache();
                        }
                        userRetentionPolicyCache.LoadStoreTagDataFromStore(itemStore);
                        if (!userRetentionPolicyCache.UnderRetentionPolicy)
                        {
                            userRetentionPolicyCache = RetentionPolicyCheck.CachedOffState;
                        }
                        cachedState.State[5] = userRetentionPolicyCache;
                        RetentionPolicyCheck.Tracer.TraceDebug((long)itemStore.GetHashCode(), "{0}: The MRM settings object was new or has been changed - (re)reading contents.", new object[]
                        {
                            TraceContext.Get()
                        });
                    }
                    finally
                    {
                        cachedState.DowngradeFromWriterLock(ref lockCookie);
                    }
                }
            }
            finally
            {
                cachedState.ReleaseReaderLock();
            }
            RetentionPolicyCheck.Tracer.TraceDebug <object, bool>((long)itemStore.GetHashCode(), "{0}: Mailbox under retention policy: {1}", TraceContext.Get(), userRetentionPolicyCache.UnderRetentionPolicy);
            RetentionPolicyCheck.TracerPfd.TracePfd <int, object, bool>((long)itemStore.GetHashCode(), "PFD IWR {0} {1}: Mailbox under retention policy: {2}", 19223, TraceContext.Get(), userRetentionPolicyCache.UnderRetentionPolicy);
            return(userRetentionPolicyCache);
        }
Example #5
0
 protected void CheckFolderInitState(MailboxSession sessionWithBestAccess)
 {
     if (this.folderIdState == FolderIdState.FolderIdDefered)
     {
         this.folderIdState = this.InternalInitFolders(sessionWithBestAccess);
     }
     if (this.folderIdState != FolderIdState.FolderIdSuccess)
     {
         ExTraceGlobals.SessionTracer.TraceDebug((long)sessionWithBestAccess.GetHashCode(), "Recoverable Items folders/folderIds missing");
         throw new RecoverableItemsAccessDeniedException("Recoverable Items");
     }
 }
Example #6
0
        private static bool TryOpenFolder(MailboxSession itemStore, out MapiFolder nonIpmSubtreeFolder, out MapiFolder oofHistoryFolder)
        {
            MapiStore _ContainedMapiStore = itemStore.__ContainedMapiStore;

            nonIpmSubtreeFolder = _ContainedMapiStore.GetNonIpmSubtreeFolder();
            oofHistoryFolder    = null;
            if (nonIpmSubtreeFolder == null)
            {
                OofHistory.Tracer.TraceError((long)itemStore.GetHashCode(), "Unable to open the non ipm subtree folder, OOF history operation is not executed.");
                return(false);
            }
            try
            {
                oofHistoryFolder = nonIpmSubtreeFolder.OpenSubFolderByName("Freebusy Data");
            }
            catch (MapiExceptionNotFound)
            {
                OofHistory.Tracer.TraceError <string>((long)itemStore.GetHashCode(), "Unable to open the OOF history folder {0}, OOF history operation is not executed.", "Freebusy Data");
                return(false);
            }
            return(true);
        }
Example #7
0
        private static MeetingInquiryAction GetReviveAction(CalendarVersionStoreGateway cvsGateway, MailboxSession session, CalendarItemBase deletedVersion)
        {
            MeetingInquiryAction result;

            if (deletedVersion == null)
            {
                result = MeetingInquiryAction.DeletedVersionNotFound;
            }
            else
            {
                bool flag = false;
                try
                {
                    if (session.Capabilities.CanHaveDelegateUsers)
                    {
                        DelegateUserCollection delegateUserCollection = new DelegateUserCollection(session);
                        flag = (delegateUserCollection.Count > 0);
                    }
                }
                catch (DelegateUserNoFreeBusyFolderException)
                {
                    ExTraceGlobals.MeetingMessageTracer.Information((long)session.GetHashCode(), "Storage.MeetingInquiryMessage.GetReviveAction: NoFreeBusyData Folder, failing to get delegate rule type.");
                }
                catch (ObjectNotFoundException)
                {
                    ExTraceGlobals.MeetingMessageTracer.Information((long)session.GetHashCode(), "Storage.MeetingInquiryMessage.GetReviveAction: No delegates found, failing to get delegate rule type.");
                }
                if (!flag)
                {
                    result = (MeetingInquiryMessage.PairWithCancellation(cvsGateway, deletedVersion, session) ? MeetingInquiryAction.PairedCancellationFound : MeetingInquiryAction.ReviveMeeting);
                }
                else
                {
                    ExTraceGlobals.MeetingMessageTracer.TraceDebug <string, GlobalObjectId>((long)session.GetHashCode(), "Storage.MeetingInquiryMessage::GetReviveAction. Mailbox {0} has delegates so we can't get the cancellation from version store. Skipping GOID {1}", session.DisplayName, deletedVersion.GlobalObjectId);
                    result = MeetingInquiryAction.HasDelegates;
                }
            }
            return(result);
        }
Example #8
0
        public static DelegateRuleType GetDelegateRuleType(MailboxSession session)
        {
            DelegateRuleType result = DelegateRuleType.ForwardAndDelete;
            FolderSaveResult folderSaveResult;

            byte[] freeBusyMsgId = FreeBusyUtil.GetFreeBusyMsgId(session, out folderSaveResult);
            if (freeBusyMsgId != null && freeBusyMsgId.Length > 0)
            {
                try
                {
                    using (MessageItem messageItem = MessageItem.Bind(session, StoreObjectId.FromProviderSpecificId(freeBusyMsgId), FreeBusyUtil.FreeBusyMessageProperties))
                    {
                        result = FreeBusyUtil.GetDelegateRuleType(messageItem);
                    }
                }
                catch (ObjectNotFoundException)
                {
                    ExTraceGlobals.CalendarLoggingTracer.TraceDebug((long)session.GetHashCode(), "FreeBusyUtil::GetDelegateRuleType. No FreeBusyMessage");
                }
            }
            return(result);
        }
        public static ExchangeMailboxAuditGroupRecord CreateMailboxGroupRecord(MailboxSession mailboxSession, MailboxAuditOperations operation, COWSettings settings, LogonType effectiveLogonType, bool externalAccess, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, IDictionary <StoreObjectId, FolderAuditInfo> folders, IDictionary <StoreObjectId, ItemAuditInfo> items, IDictionary <StoreObjectId, FolderAuditInfo> parentFolders)
        {
            Util.ThrowOnNullArgument(settings, "settings");
            ExchangeMailboxAuditGroupRecord exchangeMailboxAuditGroupRecord = new ExchangeMailboxAuditGroupRecord();

            AuditRecordFactory.Fill(exchangeMailboxAuditGroupRecord, mailboxSession, operation, (result == null) ? OperationResult.Failed : result.OperationResult, effectiveLogonType, externalAccess);
            if (settings.CurrentFolderId != null)
            {
                exchangeMailboxAuditGroupRecord.Folder    = (exchangeMailboxAuditGroupRecord.Folder ?? new ExchangeFolder());
                exchangeMailboxAuditGroupRecord.Folder.Id = string.Format(CultureInfo.InvariantCulture, "{0}", new object[]
                {
                    settings.CurrentFolderId
                });
                FolderAuditInfo folderAuditInfo;
                parentFolders.TryGetValue(settings.CurrentFolderId, out folderAuditInfo);
                exchangeMailboxAuditGroupRecord.Folder.PathName = ((folderAuditInfo != null) ? folderAuditInfo.PathName : AuditRecordFactory.GetCurrentFolderPathName(mailboxSession, settings));
            }
            bool flag = destinationSession != null && mailboxSession != destinationSession;

            exchangeMailboxAuditGroupRecord.CrossMailboxOperation = new bool?(flag);
            MailboxSession mailboxSession2 = mailboxSession;

            if (flag && destinationSession is MailboxSession)
            {
                mailboxSession2 = (destinationSession as MailboxSession);
                exchangeMailboxAuditGroupRecord.DestMailboxGuid     = new Guid?(mailboxSession2.MailboxOwner.MailboxInfo.MailboxGuid);
                exchangeMailboxAuditGroupRecord.DestMailboxOwnerUPN = string.Format(CultureInfo.InvariantCulture, "{0}", new object[]
                {
                    mailboxSession2.MailboxOwner.MailboxInfo.PrimarySmtpAddress
                });
                if (mailboxSession2.MailboxOwner.Sid != null)
                {
                    exchangeMailboxAuditGroupRecord.DestMailboxOwnerSid = string.Format(CultureInfo.InvariantCulture, "{0}", new object[]
                    {
                        mailboxSession2.MailboxOwner.Sid
                    });
                    if (mailboxSession2.MailboxOwner.MasterAccountSid != null)
                    {
                        exchangeMailboxAuditGroupRecord.DestMailboxOwnerMasterAccountSid = string.Format(CultureInfo.InvariantCulture, "{0}", new object[]
                        {
                            mailboxSession2.MailboxOwner.MasterAccountSid
                        });
                    }
                }
            }
            if (destinationFolderId != null)
            {
                exchangeMailboxAuditGroupRecord.DestFolder    = (exchangeMailboxAuditGroupRecord.DestFolder ?? new ExchangeFolder());
                exchangeMailboxAuditGroupRecord.DestFolder.Id = string.Format(CultureInfo.InvariantCulture, "{0}", new object[]
                {
                    destinationFolderId
                });
                string    text = null;
                Exception ex   = null;
                try
                {
                    using (Folder folder = Folder.Bind(mailboxSession2, destinationFolderId, new PropertyDefinition[]
                    {
                        FolderSchema.FolderPathName
                    }))
                    {
                        if (folder != null)
                        {
                            text = (folder.TryGetProperty(FolderSchema.FolderPathName) as string);
                            if (text != null)
                            {
                                text = text.Replace(COWSettings.StoreIdSeparator, '\\');
                            }
                        }
                    }
                }
                catch (StorageTransientException ex2)
                {
                    ex = ex2;
                }
                catch (StoragePermanentException ex3)
                {
                    ex = ex3;
                }
                if (ex != null)
                {
                    ExTraceGlobals.SessionTracer.TraceError <StoreObjectId, Exception>((long)mailboxSession.GetHashCode(), "[GroupOperationAuditEventRecordAdapter::ToString] failed to get FolderPathName property of destination folder {0}. Exception: {1}", destinationFolderId, ex);
                }
                if (text != null)
                {
                    exchangeMailboxAuditGroupRecord.DestFolder.PathName = text;
                }
            }
            foreach (KeyValuePair <StoreObjectId, FolderAuditInfo> keyValuePair in folders)
            {
                StoreObjectId   key   = keyValuePair.Key;
                FolderAuditInfo value = keyValuePair.Value;
                if (settings.CurrentFolderId == null || !key.Equals(settings.CurrentFolderId))
                {
                    exchangeMailboxAuditGroupRecord.Folders = (exchangeMailboxAuditGroupRecord.Folders ?? new List <ExchangeFolder>(folders.Count));
                    ExchangeFolder exchangeFolder = new ExchangeFolder();
                    exchangeMailboxAuditGroupRecord.Folders.Add(exchangeFolder);
                    exchangeFolder.Id = string.Format(CultureInfo.InvariantCulture, "{0}", new object[]
                    {
                        key
                    });
                    if (value.PathName != null)
                    {
                        exchangeFolder.PathName = value.PathName;
                    }
                }
            }
            foreach (KeyValuePair <StoreObjectId, ItemAuditInfo> keyValuePair2 in items)
            {
                StoreObjectId key2   = keyValuePair2.Key;
                ItemAuditInfo value2 = keyValuePair2.Value;
                exchangeMailboxAuditGroupRecord.SourceItems = (exchangeMailboxAuditGroupRecord.SourceItems ?? new List <ExchangeItem>(items.Count));
                ExchangeItem exchangeItem = new ExchangeItem();
                exchangeMailboxAuditGroupRecord.SourceItems.Add(exchangeItem);
                exchangeItem.Id = string.Format(CultureInfo.InvariantCulture, "{0}", new object[]
                {
                    key2
                });
                if (value2.Subject != null)
                {
                    exchangeItem.Subject = value2.Subject;
                }
                FolderAuditInfo folderAuditInfo2;
                if (value2.ParentFolderId != null && parentFolders.TryGetValue(value2.ParentFolderId, out folderAuditInfo2))
                {
                    exchangeItem.ParentFolder          = (exchangeItem.ParentFolder ?? new ExchangeFolder());
                    exchangeItem.ParentFolder.PathName = folderAuditInfo2.PathName;
                }
            }
            return(exchangeMailboxAuditGroupRecord);
        }
        internal static string GetFolderPathForFolderId(MailboxSession session, StoreObjectId folderId)
        {
            StringBuilder stringBuilder = new StringBuilder(128);
            StoreObjectId storeObjectId = folderId;
            int           num           = 0;
            int           num2          = 10;

            while (storeObjectId != null && num < num2)
            {
                using (Folder folder = Folder.Bind(session, storeObjectId))
                {
                    num++;
                    if (stringBuilder.Length == 0)
                    {
                        stringBuilder.Append(folder.DisplayName);
                    }
                    else
                    {
                        stringBuilder.Insert(0, "\\");
                        stringBuilder.Insert(0, folder.DisplayName);
                    }
                    num++;
                    if (folder.ParentId != null && storeObjectId.Equals(folder.ParentId))
                    {
                        break;
                    }
                    storeObjectId = folder.ParentId;
                }
            }
            if (num >= num2)
            {
                ExTraceGlobals.SessionTracer.TraceWarning <int, string, string>((long)session.GetHashCode(), "AnalysisGroupData.GetFolderPathForFolderId hit the max {0} folder depth for folder if {1}, path {2}.", num, folderId.ToString(), stringBuilder.ToString());
                stringBuilder.Insert(0, "...\\");
            }
            return(stringBuilder.ToString());
        }
Example #11
0
 // Token: 0x06000662 RID: 1634 RVA: 0x000309BC File Offset: 0x0002EBBC
 protected override void InvokeInternal()
 {
     if (this.IsSystemArbitrationMailbox() && this.IsDumpsterOverQuota())
     {
         this.isOverQuota = true;
         if (AuditQuotaEnforcer.Tracer.IsTraceEnabled(TraceType.DebugTrace))
         {
             AuditQuotaEnforcer.Tracer.TraceDebug <AuditQuotaEnforcer>((long)this.GetHashCode(), "{0}: The system arbitration mailbox is over dumpster warning quota. Processing the adminaudits folder.", this);
         }
         MailboxSession mailboxSession  = base.MailboxDataForTags.MailboxSession;
         MailboxSession mailboxSession2 = null;
         try
         {
             mailboxSession2 = MailboxSession.OpenAsSystemService(mailboxSession.MailboxOwner, CultureInfo.InvariantCulture, mailboxSession.ClientInfoString);
         }
         catch (ObjectNotFoundException arg)
         {
             if (AuditQuotaEnforcer.Tracer.IsTraceEnabled(TraceType.DebugTrace))
             {
                 AuditQuotaEnforcer.Tracer.TraceDebug <IExchangePrincipal, ObjectNotFoundException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService because the mailbox is missing. {1}", mailboxSession.MailboxOwner, arg);
             }
         }
         catch (StorageTransientException arg2)
         {
             if (AuditQuotaEnforcer.Tracer.IsTraceEnabled(TraceType.WarningTrace))
             {
                 AuditQuotaEnforcer.Tracer.TraceWarning <IExchangePrincipal, MailboxSession, StorageTransientException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService: {1}.\nError:\n{2}", mailboxSession.MailboxOwner, mailboxSession, arg2);
             }
         }
         catch (StoragePermanentException arg3)
         {
             if (AuditQuotaEnforcer.Tracer.IsTraceEnabled(TraceType.ErrorTrace))
             {
                 AuditQuotaEnforcer.Tracer.TraceError <IExchangePrincipal, MailboxSession, StoragePermanentException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService: {1}.\nError:\n{2}", mailboxSession.MailboxOwner, mailboxSession, arg3);
             }
         }
         if (mailboxSession2 != null)
         {
             try
             {
                 base.MailboxDataForTags.MailboxSession = mailboxSession2;
                 base.InvokeInternal();
             }
             finally
             {
                 base.MailboxDataForTags.MailboxSession = mailboxSession;
                 mailboxSession2.Dispose();
                 mailboxSession2 = null;
             }
         }
         if (base.IsEnabled)
         {
             this.LogAuditsCleanupEvent();
         }
     }
 }
Example #12
0
        internal static void RemoveOofHistoryEntriesWithProperty(MailboxSession itemStore, bool oofEnabled, OofHistory.PropId propId, byte[] propValue)
        {
            MapiFolder mapiFolder  = null;
            MapiFolder mapiFolder2 = null;
            MapiStream mapiStream  = null;
            bool       flag        = false;

            byte[] initialBytes = oofEnabled ? OofHistory.InitialBytesOofStateOn : OofHistory.InitialBytesOofStateOff;
            try
            {
                if (OofHistory.TryOpenFolder(itemStore, out mapiFolder, out mapiFolder2))
                {
                    long hashCode = (long)itemStore.GetHashCode();
                    bool flag2;
                    mapiStream = OofHistory.OpenAndLockStream(mapiFolder2, initialBytes, hashCode, out flag2);
                    flag       = true;
                    if (!flag2)
                    {
                        int num;
                        if (OofHistory.TryGetStreamLengthForEntryRemoval(hashCode, mapiStream, out num))
                        {
                            byte[] buffer;
                            if (OofHistory.TryReadAllFromStream(hashCode, mapiStream, num, out buffer))
                            {
                                int num2 = OofHistory.RemoveEntriesWithProperty(num, buffer, propId, propValue, hashCode);
                                if (num2 < num)
                                {
                                    mapiStream.Seek(0L, SeekOrigin.Begin);
                                    mapiStream.Write(buffer, 0, num2);
                                    mapiStream.SetLength((long)num2);
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                if (mapiStream != null)
                {
                    try
                    {
                        if (flag)
                        {
                            mapiStream.UnlockRegion(0L, 1L, 1);
                        }
                    }
                    finally
                    {
                        mapiStream.Dispose();
                    }
                }
                if (mapiFolder != null)
                {
                    mapiFolder.Dispose();
                    mapiFolder = null;
                }
                if (mapiFolder2 != null)
                {
                    mapiFolder2.Dispose();
                    mapiFolder2 = null;
                }
            }
        }
Example #13
0
        internal static void ClearOofHistory(MailboxSession itemStore, bool oofEnabled)
        {
            MapiFolder mapiFolder  = null;
            MapiFolder mapiFolder2 = null;
            MapiStream mapiStream  = null;
            bool       flag        = false;

            byte[] initialBytes = oofEnabled ? OofHistory.InitialBytesOofStateOn : OofHistory.InitialBytesOofStateOff;
            try
            {
                if (OofHistory.TryOpenFolder(itemStore, out mapiFolder, out mapiFolder2))
                {
                    long num = (long)itemStore.GetHashCode();
                    bool flag2;
                    mapiStream = OofHistory.OpenAndLockStream(mapiFolder2, initialBytes, num, out flag2);
                    flag       = true;
                    if (!flag2)
                    {
                        byte[] array = new byte[2];
                        if (2 != mapiStream.Read(array, 0, 2))
                        {
                            OofHistory.ResetOofHistoryProperty(mapiStream, initialBytes, num);
                        }
                        else
                        {
                            bool flag3 = 0 != array[1];
                            if (flag3 == oofEnabled)
                            {
                                OofHistory.Tracer.TraceDebug <bool>(num, "Current OOF state {0} matches in OOF history and mailbox properties, clear is not executed.", oofEnabled);
                            }
                            else
                            {
                                OofHistory.ResetOofHistoryProperty(mapiStream, initialBytes, num);
                            }
                        }
                    }
                }
            }
            finally
            {
                if (mapiStream != null)
                {
                    try
                    {
                        if (flag)
                        {
                            mapiStream.UnlockRegion(0L, 1L, 1);
                        }
                    }
                    finally
                    {
                        mapiStream.Dispose();
                    }
                }
                if (mapiFolder != null)
                {
                    mapiFolder.Dispose();
                    mapiFolder = null;
                }
                if (mapiFolder2 != null)
                {
                    mapiFolder2.Dispose();
                    mapiFolder2 = null;
                }
            }
        }
Example #14
0
        private static bool ShouldSetupNotificationManagerForUser(MailboxSession userMailboxSession)
        {
            SyncUtilities.ThrowIfArgumentNull("userMailboxSession", userMailboxSession);
            bool result;

            try
            {
                bool flag = SubscriptionManager.DoesUserHasAnyActiveConnectedAccounts(userMailboxSession, AggregationSubscriptionType.AllEMail);
                result = flag;
            }
            catch (LocalizedException arg)
            {
                ExTraceGlobals.ConnectedAccountsTracer.TraceError <Guid, SmtpAddress, LocalizedException>((long)userMailboxSession.GetHashCode(), "DoesUserHasActiveConnectedAccounts failed for User (MailboxGuid:{0}, PrimarySmtpAddress:{1}), with error:{2}. We will assume that user has active connected accounts.", userMailboxSession.MailboxGuid, userMailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress, arg);
                result = true;
            }
            return(result);
        }
        // Token: 0x06000641 RID: 1601 RVA: 0x0002FDBC File Offset: 0x0002DFBC
        protected override void InvokeInternal()
        {
            if (!base.IsEnabled)
            {
                return;
            }
            MailboxSession mailboxSession  = base.MailboxDataForTags.MailboxSession;
            MailboxSession mailboxSession2 = null;

            try
            {
                mailboxSession2 = MailboxSession.OpenAsSystemService(mailboxSession.MailboxOwner, CultureInfo.InvariantCulture, mailboxSession.ClientInfoString);
            }
            catch (ObjectNotFoundException arg)
            {
                if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    AuditExpirationEnforcer.Tracer.TraceDebug <IExchangePrincipal, ObjectNotFoundException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService because the mailbox is missing. {1}", mailboxSession.MailboxOwner, arg);
                }
            }
            catch (StorageTransientException arg2)
            {
                if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.WarningTrace))
                {
                    AuditExpirationEnforcer.Tracer.TraceWarning <IExchangePrincipal, MailboxSession, StorageTransientException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService: {1}.\nError:\n{2}", mailboxSession.MailboxOwner, mailboxSession, arg2);
                }
            }
            catch (StoragePermanentException arg3)
            {
                if (AuditExpirationEnforcer.Tracer.IsTraceEnabled(TraceType.ErrorTrace))
                {
                    AuditExpirationEnforcer.Tracer.TraceError <IExchangePrincipal, MailboxSession, StoragePermanentException>((long)mailboxSession.GetHashCode(), "{0}: Failed to reopen the session with SystemService: {1}.\nError:\n{2}", mailboxSession.MailboxOwner, mailboxSession, arg3);
                }
            }
            if (mailboxSession2 != null)
            {
                try
                {
                    base.MailboxDataForTags.MailboxSession = mailboxSession2;
                    base.InvokeInternal();
                }
                finally
                {
                    base.MailboxDataForTags.MailboxSession = mailboxSession;
                    mailboxSession2.Dispose();
                    mailboxSession2 = null;
                }
            }
        }
Example #16
0
 private static bool ShouldSetupNotificationManagerForUser(MailboxSession userMailboxSession)
 {
     SyncUtilities.ThrowIfArgumentNull("userMailboxSession", userMailboxSession);
     try
     {
         IExchangePrincipal mailboxOwner = userMailboxSession.MailboxOwner;
         ADUser             aduser       = DirectoryHelper.ReadADRecipient(mailboxOwner.MailboxInfo.MailboxGuid, mailboxOwner.MailboxInfo.IsArchive, userMailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid)) as ADUser;
         if (aduser != null)
         {
             AggregatedAccountHelper      aggregatedAccountHelper = new AggregatedAccountHelper(userMailboxSession, aduser);
             List <AggregatedAccountInfo> listOfAccounts          = aggregatedAccountHelper.GetListOfAccounts();
             if (listOfAccounts != null)
             {
                 return(listOfAccounts.Count > 0);
             }
         }
     }
     catch (LocalizedException arg)
     {
         ExTraceGlobals.ConnectedAccountsTracer.TraceError <Guid, SmtpAddress, LocalizedException>((long)userMailboxSession.GetHashCode(), "MrsConnectedAccountsNotificationManager.ShouldSetupNotificationManagerForUser failed for User (MailboxGuid:{0}, PrimarySmtpAddress:{1}), with error:{2}. We will assume that user has active connected accounts.", userMailboxSession.MailboxGuid, userMailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress, arg);
     }
     return(false);
 }
Example #17
0
        private static bool WouldTryToRepairIfMissing(CalendarVersionStoreGateway cvsGateway, GlobalObjectId globalObjectId, MailboxSession session, MeetingInquiryMessage message, bool performRepair, byte[] calendarFolderId, out MeetingInquiryAction predictedAction)
        {
            VersionedId versionedId;
            bool        result;

            if (MeetingInquiryMessage.TryGetCancelledVersionIdFromCvs(cvsGateway, globalObjectId, session, calendarFolderId, out versionedId))
            {
                if (performRepair)
                {
                    message.LocationIdentifierHelperInstance.SetLocationIdentifier(47383U, LastChangeAction.SendMeetingCancellations);
                    message.SendCancellationBasedOnFoundIntent(versionedId);
                }
                predictedAction = MeetingInquiryAction.SendCancellation;
                result          = true;
            }
            else
            {
                if (versionedId != null)
                {
                    using (CalendarItemBase calendarItemBase = CalendarItemBase.Bind(session, versionedId))
                    {
                        predictedAction = MeetingInquiryMessage.GetReviveAction(cvsGateway, session, calendarItemBase);
                        if (predictedAction == MeetingInquiryAction.ReviveMeeting)
                        {
                            if (performRepair)
                            {
                                predictedAction = message.TryReviveMeeting(calendarItemBase);
                            }
                            result = true;
                        }
                        else
                        {
                            result = false;
                        }
                        return(result);
                    }
                }
                ExTraceGlobals.MeetingMessageTracer.TraceDebug <string, GlobalObjectId>((long)session.GetHashCode(), "Storage.MeetingInquiryMessage::Process. Couldn't find deletion on mailbox {0}. Skipping GOID {1}", session.DisplayName, globalObjectId);
                predictedAction = MeetingInquiryAction.DeletedVersionNotFound;
                result          = false;
            }
            return(result);
        }