コード例 #1
0
 private void SetTaskFolderId(byte[] entryId)
 {
     if (IdConverter.IsFolderId(entryId))
     {
         this.taskFolderObjectId = StoreObjectId.FromProviderSpecificIdOrNull(entryId);
     }
 }
コード例 #2
0
        internal static TaskGroupEntryInfo GetTaskGroupEntryInfoFromRow(IStorePropertyBag row)
        {
            VersionedId versionedId = (VersionedId)row.TryGetProperty(ItemSchema.Id);

            byte[] valueOrDefault  = row.GetValueOrDefault <byte[]>(TaskGroupEntrySchema.NodeEntryId, null);
            byte[] valueOrDefault2 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null);
            string valueOrDefault3 = row.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty);

            byte[] valueOrDefault4 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.Ordinal, null);
            row.GetValueOrDefault <byte[]>(TaskGroupEntrySchema.StoreEntryId, null);
            ExDateTime valueOrDefault5 = row.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue);

            row.GetValueOrDefault <FolderTreeDataType>(FolderTreeDataSchema.Type, FolderTreeDataType.NormalFolder);
            FolderTreeDataFlags valueOrDefault6 = row.GetValueOrDefault <FolderTreeDataFlags>(FolderTreeDataSchema.FolderTreeDataFlags, FolderTreeDataFlags.None);
            Guid safeGuidFromByteArray          = FolderTreeData.GetSafeGuidFromByteArray(valueOrDefault2);

            if (safeGuidFromByteArray.Equals(Guid.Empty))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found TaskGroupEntry with invalid parent group class id. ArrayLength: {0}", (valueOrDefault2 == null) ? -1 : valueOrDefault2.Length);
                return(null);
            }
            if (IdConverter.IsFolderId(valueOrDefault))
            {
                StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(valueOrDefault);
                if ((valueOrDefault6 & FolderTreeDataFlags.IsDefaultStore) == FolderTreeDataFlags.IsDefaultStore)
                {
                    return(new TaskGroupEntryInfo(valueOrDefault3, versionedId, storeObjectId, safeGuidFromByteArray, valueOrDefault4, valueOrDefault5));
                }
                ExTraceGlobals.StorageTracer.TraceDebug <StoreObjectType, string, VersionedId>(0L, "Found TaskGroupEntry of type {0} referencing a non-task folder. ObjectType: {0}. TaskFfolderName: {1}. Id: {2}.", storeObjectId.ObjectType, valueOrDefault3, versionedId);
            }
            return(null);
        }
コード例 #3
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
 public static GuidGlobCount MessageGuidGlobCountFromEntryId(byte[] entryId)
 {
     if (!IdConverter.IsMessageId(entryId))
     {
         throw new CorruptDataException(ServerStrings.MapiInvalidId, new ArgumentException("Invalid message id size.", "entryId"));
     }
     return(IdConverter.ExtractGuidGlobCountFromEntryId(entryId, 46));
 }
コード例 #4
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
        public StoreObjectId CreateMessageIdFromSvrEId(byte[] svrEId)
        {
            long num  = 0L;
            long num2 = 0L;
            int  num3 = 0;

            if (IdConverter.ParseOursServerEntryId(svrEId, out num, out num2, out num3) && num != 0L && num2 != 0L && num3 == 0)
            {
                return(this.CreateMessageId(num, num2));
            }
            throw new CorruptDataException(ServerStrings.MapiInvalidId, new ArgumentException("Invalid SvrEid format, which should be 21 bytes, the first byte should be 1 and the last four bytes should be 0.", "svrEId"));
        }
コード例 #5
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
 public byte[] GetLongTermIdFromId(StoreObjectId folderOrMessageId)
 {
     if (IdConverter.IsFolderId(folderOrMessageId))
     {
         return(this.GetLongTermIdFromId(this.GetFidFromId(folderOrMessageId)));
     }
     if (IdConverter.IsMessageId(folderOrMessageId))
     {
         return(this.GetLongTermIdFromId(this.GetMidFromMessageId(folderOrMessageId)));
     }
     throw new ArgumentException("Not a valid folder or message ID", "folderOrMessageId");
 }
コード例 #6
0
        public CowClientOperationSensitivity SkipGroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, bool onBeforeNotification, bool onDumpster, CallbackContext callbackContext)
        {
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
            MailboxSession mailboxSession = sourceSession as MailboxSession;

            if (mailboxSession == null)
            {
                return(CowClientOperationSensitivity.Skip);
            }
            if (onBeforeNotification && (COWTriggerAction.Copy == operation || COWTriggerAction.HardDelete == operation || COWTriggerAction.Move == operation || COWTriggerAction.MoveToDeletedItems == operation || COWTriggerAction.SoftDelete == operation))
            {
                StoreObjectId auditsFolderId         = dumpster.AuditsFolderId;
                StoreObjectId adminAuditLogsFolderId = dumpster.AdminAuditLogsFolderId;
                if (settings.CurrentFolderId != null && (COWTriggerAction.HardDelete != operation || LogonType.SystemService != sourceSession.LogonType || !settings.IsMrmAction()))
                {
                    this.CheckAccessOnAuditFolders(mailboxSession, settings.CurrentFolderId, dumpster, false);
                }
                if (itemIds != null)
                {
                    foreach (StoreObjectId storeObjectId in itemIds)
                    {
                        if (storeObjectId != null)
                        {
                            if (storeObjectId.IsMessageId)
                            {
                                if (settings.CurrentFolderId == null && (COWTriggerAction.HardDelete != operation || LogonType.SystemService != sourceSession.LogonType || !settings.IsMrmAction()))
                                {
                                    StoreObjectId parentIdFromMessageId = IdConverter.GetParentIdFromMessageId(storeObjectId);
                                    if (parentIdFromMessageId.Equals(auditsFolderId))
                                    {
                                        throw new AccessDeniedException(ServerStrings.ExAuditsUpdateDenied);
                                    }
                                    if (parentIdFromMessageId.Equals(adminAuditLogsFolderId))
                                    {
                                        throw new AccessDeniedException(ServerStrings.ExAdminAuditLogsUpdateDenied);
                                    }
                                    if (dumpster.IsAuditFolder(parentIdFromMessageId))
                                    {
                                        throw new AccessDeniedException((auditsFolderId != null) ? ServerStrings.ExAuditsUpdateDenied : ServerStrings.ExAdminAuditLogsUpdateDenied);
                                    }
                                }
                            }
                            else if (storeObjectId.IsFolderId)
                            {
                                this.CheckAccessOnAuditFolders(mailboxSession, storeObjectId, dumpster, true);
                            }
                        }
                    }
                }
            }
            return(CowClientOperationSensitivity.Skip);
        }
コード例 #7
0
 public static CopyToFolderAction Create(StoreObjectId folderId, Rule rule)
 {
     ActionBase.CheckParams(new object[]
     {
         rule,
         folderId
     });
     if (!IdConverter.IsFolderId(folderId))
     {
         throw new ArgumentException("folderId");
     }
     return(new CopyToFolderAction(folderId, rule));
 }
コード例 #8
0
 public static ServerReplyMessageAction Create(StoreObjectId messageId, Guid guidTemplate, Rule rule)
 {
     ActionBase.CheckParams(new object[]
     {
         rule,
         messageId
     });
     if (!IdConverter.IsMessageId(messageId))
     {
         throw new ArgumentException("messageId");
     }
     return(new ServerReplyMessageAction(messageId, guidTemplate, rule));
 }
コード例 #9
0
 internal override byte[] GetEntryId(DefaultFolderContext context)
 {
     byte[][] array = this.GetLocationPropertyBag(context).TryGetProperty(this.Property) as byte[][];
     if (array == null || array.Length <= this.index)
     {
         return(null);
     }
     byte[] array2 = array[this.index];
     if (!IdConverter.IsFolderId(array2))
     {
         return(null);
     }
     return(array2);
 }
コード例 #10
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
 public StoreObjectId GetSessionSpecificId(StoreObjectId storeObjectId)
 {
     if (this.session is PublicFolderSession)
     {
         if (IdConverter.IsMessageId(storeObjectId))
         {
             return(this.CreateMessageId(this.GetFidFromId(storeObjectId), this.GetMidFromMessageId(storeObjectId)));
         }
         if (IdConverter.IsFolderId(storeObjectId))
         {
             return(this.CreateFolderId(this.GetFidFromId(storeObjectId)));
         }
     }
     return(storeObjectId);
 }
コード例 #11
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
 public static bool IsValidMessageEntryId(byte[] entryId)
 {
     if (!IdConverter.IsMessageId(entryId))
     {
         return(false);
     }
     for (int i = 62; i < 68; i++)
     {
         if (entryId[i] != 0)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #12
0
 public static MoveToFolderAction Create(StoreObjectId folderId, Rule rule)
 {
     ActionBase.CheckParams(new object[]
     {
         rule,
         folderId
     });
     if (!IdConverter.IsFolderId(folderId))
     {
         rule.ThrowValidateException(delegate
         {
             throw new ArgumentNullException("folderId");
         }, "folderId");
     }
     return(new MoveToFolderAction(folderId, rule));
 }
コード例 #13
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
 public static void ExpandIdSet(IdSet idset, Action <byte[]> action)
 {
     foreach (GuidGlobCountSet guidGlobCountSet in idset)
     {
         foreach (GlobCountRange globCountRange in guidGlobCountSet.GlobCountSet)
         {
             for (ulong num = globCountRange.LowBound; num <= globCountRange.HighBound; num += 1UL)
             {
                 byte[] array     = new byte[22];
                 int    dstOffset = ExBitConverter.Write(guidGlobCountSet.Guid, array, 0);
                 Buffer.BlockCopy(IdConverter.GlobcntIntoByteArray(num), 0, array, dstOffset, 6);
                 action(array);
             }
         }
     }
 }
コード例 #14
0
        internal static DeferredAction Create(MailboxSession session, StoreObjectId ruleFolderId, string providerName)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(ruleFolderId, "ruleFolderId");
            Util.ThrowOnNullArgument(providerName, "providerName");
            if (!IdConverter.IsFolderId(ruleFolderId))
            {
                throw new ArgumentException(ServerStrings.InvalidFolderId(ruleFolderId.ToBase64String()));
            }
            DeferredAction deferredAction = new DeferredAction();

            deferredAction.actions = new List <RuleAction>();
            deferredAction.ruleIds = new List <long>();
            deferredAction.message = MessageItem.Create(session, session.GetDefaultFolderId(DefaultFolderType.DeferredActionFolder));
            deferredAction.message[InternalSchema.ItemClass]         = "IPC.Microsoft Exchange 4.0.Deferred Action";
            deferredAction.message[InternalSchema.RuleFolderEntryId] = ruleFolderId.ProviderLevelItemId;
            deferredAction.message[InternalSchema.RuleProvider]      = providerName;
            return(deferredAction);
        }
コード例 #15
0
 public static byte[] GetFreeBusyMsgId(MailboxSession session, out FolderSaveResult result)
 {
     result = null;
     byte[] array = null;
     using (Folder folder = Folder.Bind(session, DefaultFolderType.Inbox, new PropertyDefinition[]
     {
         InternalSchema.FreeBusyEntryIds
     }))
     {
         byte[][] array2 = folder.TryGetProperty(InternalSchema.FreeBusyEntryIds) as byte[][];
         if (array2 != null)
         {
             if (array2.Length > 1)
             {
                 array = array2[1];
                 try
                 {
                     StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(array);
                     if (!IdConverter.IsMessageId(storeObjectId))
                     {
                         ExTraceGlobals.CalendarLoggingTracer.TraceError(0L, "FreeBusyUtil::GetFreeBusyMsgId. The extracted storeObjectId is not a valid MessageId");
                         array = null;
                     }
                 }
                 catch (CorruptDataException)
                 {
                     ExTraceGlobals.CalendarLoggingTracer.TraceError(0L, "FreeBusyUtil::GetFreeBusyMsgId. The localFreeBusyMsgId is not a valid entry id");
                     array = null;
                 }
             }
             if (array == null || array.Length == 0)
             {
                 array = FreeBusyUtil.FindFreeBusyMsgId(session);
                 if (array == null)
                 {
                     ExTraceGlobals.CalendarLoggingTracer.TraceDebug(0L, "FreeBusyUtil::GetFreeBusyMsgId. Couldn't find a free busy message. Attempting to create one.");
                     array = FreeBusyUtil.CreateFreeBusyMessage(session, out result);
                 }
             }
         }
     }
     return(array);
 }
コード例 #16
0
        private DefaultFolderData InitializeFolderIdPrivate()
        {
            ExTraceGlobals.DefaultFoldersTracer.TraceDebug <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::InitializeFolderId. The default folder ID is about to be initialized. defaultFolder = {0}.", this);
            byte[] array = this.defaultFolderInfo.EntryIdStrategy.GetEntryId(this.context);
            if (!IdConverter.IsFolderId(array))
            {
                array = null;
                ExTraceGlobals.DefaultFoldersTracer.TraceError <DefaultFolder>((long)this.GetHashCode(), "DefaultFolder::InitializeFolderId. Invalid entry id found. defaultFolder = {0}.", this);
            }
            DefaultFolderData result;

            if (array != null)
            {
                result = new DefaultFolderData(StoreObjectId.FromProviderSpecificId(array, this.StoreObjectType), true, false);
            }
            else
            {
                result = new DefaultFolderData(null, true, false);
            }
            return(result);
        }
コード例 #17
0
 public bool SkipItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, bool onBeforeNotification, bool onDumpster, bool success, CallbackContext callbackContext)
 {
     EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
     EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
     if (onBeforeNotification && COWTriggerAction.Update == operation)
     {
         if (settings.CurrentFolderId != null)
         {
             if (settings.CurrentFolderId.Equals(dumpster.AuditsFolderId))
             {
                 throw new AccessDeniedException(ServerStrings.ExAuditsUpdateDenied);
             }
             if (settings.CurrentFolderId.Equals(dumpster.AdminAuditLogsFolderId))
             {
                 throw new AccessDeniedException(ServerStrings.ExAdminAuditLogsUpdateDenied);
             }
             if (dumpster.IsAuditFolder(settings.CurrentFolderId))
             {
                 throw new AccessDeniedException((dumpster.AuditsFolderId != null) ? ServerStrings.ExAuditsUpdateDenied : ServerStrings.ExAdminAuditLogsUpdateDenied);
             }
         }
         else if (itemId != null)
         {
             StoreObjectId parentIdFromMessageId = IdConverter.GetParentIdFromMessageId(itemId);
             if (parentIdFromMessageId.Equals(dumpster.AuditsFolderId))
             {
                 throw new AccessDeniedException(ServerStrings.ExAuditsUpdateDenied);
             }
             if (parentIdFromMessageId.Equals(dumpster.AdminAuditLogsFolderId))
             {
                 throw new AccessDeniedException(ServerStrings.ExAdminAuditLogsUpdateDenied);
             }
             if (dumpster.IsAuditFolder(settings.CurrentFolderId))
             {
                 throw new AccessDeniedException((dumpster.AuditsFolderId != null) ? ServerStrings.ExAuditsUpdateDenied : ServerStrings.ExAdminAuditLogsUpdateDenied);
             }
         }
     }
     return(true);
 }
コード例 #18
0
        public static DeferredError Create(MailboxSession session, StoreObjectId folderId, string providerName, long ruleId, RuleAction.Type actionType, int actionNumber, DeferredError.RuleError ruleError)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(folderId, "folderId");
            Util.ThrowOnNullArgument(providerName, "providerName");
            EnumValidator.ThrowIfInvalid <RuleAction.Type>(actionType, "actionType");
            EnumValidator.ThrowIfInvalid <DeferredError.RuleError>(ruleError, "ruleError");
            if (!IdConverter.IsFolderId(folderId))
            {
                throw new ArgumentException(ServerStrings.InvalidFolderId(folderId.ToBase64String()));
            }
            DeferredError deferredError = new DeferredError();

            deferredError.message = MessageItem.Create(session, session.GetDefaultFolderId(DefaultFolderType.DeferredActionFolder));
            deferredError.message[InternalSchema.ItemClass]         = "IPC.Microsoft Exchange 4.0.Deferred Error";
            deferredError.message[InternalSchema.RuleFolderEntryId] = folderId.ProviderLevelItemId;
            deferredError.message[InternalSchema.RuleId]            = ruleId;
            deferredError.message[InternalSchema.RuleActionType]    = (int)actionType;
            deferredError.message[InternalSchema.RuleActionNumber]  = actionNumber;
            deferredError.message[InternalSchema.RuleError]         = ruleError;
            deferredError.message[InternalSchema.RuleProvider]      = providerName;
            return(deferredError);
        }
コード例 #19
0
 public string GetItemInAllItemsFolderPath()
 {
     if (this.allItemsItemId == null)
     {
         return(string.Empty);
     }
     return(AnalysisGroupData.GetFolderPathForFolderId(this.parent.MailboxSession, IdConverter.GetParentIdFromMessageId(this.allItemsItemId)));
 }
コード例 #20
0
        internal static DefaultFolderManager Create(MailboxSession session, OpenMailboxSessionFlags openFlags, IList <DefaultFolderType> foldersToInit)
        {
            DefaultFolderManager defaultFolderManager = new DefaultFolderManager(session);
            DefaultFolderContext defaultFolderContext = new DefaultFolderContext(session, defaultFolderManager.defaultFolders);

            defaultFolderManager.context = defaultFolderContext;
            if ((openFlags & OpenMailboxSessionFlags.DeferDefaultFolderIdInitialization) == OpenMailboxSessionFlags.DeferDefaultFolderIdInitialization)
            {
                defaultFolderContext.DeferFolderIdInit = true;
            }
            if ((openFlags & OpenMailboxSessionFlags.IgnoreForcedFolderInit) == OpenMailboxSessionFlags.IgnoreForcedFolderInit)
            {
                defaultFolderContext.IgnoreForcedFolderInit = true;
            }
            if (defaultFolderContext.Session.SharedDataManager.DefaultFoldersInitialized)
            {
                defaultFolderManager.CacheDefaultFoldersFromSharedDataManager(defaultFolderContext);
                defaultFolderContext.DoneDefaultFolderInitialization();
                return(defaultFolderManager);
            }
            try
            {
                if ((openFlags & OpenMailboxSessionFlags.SuppressFolderIdPrefetch) == OpenMailboxSessionFlags.None)
                {
                    defaultFolderContext.FolderDataDictionary = defaultFolderManager.ReadFolderData();
                }
                else if (session.Capabilities.CanCreateDefaultFolders)
                {
                    string      inboxDisplayName = null;
                    CultureInfo stampedCulture   = session.Capabilities.CanHaveCulture ? session.PreferedCulture : CultureInfo.InvariantCulture;
                    if (session.LogonType != LogonType.Delegated)
                    {
                        object thisObject = null;
                        bool   flag       = false;
                        byte[] inboxFolderEntryId;
                        try
                        {
                            if (session != null)
                            {
                                session.BeginMapiCall();
                                session.BeginServerHealthCall();
                                flag = true;
                            }
                            if (StorageGlobals.MapiTestHookBeforeCall != null)
                            {
                                StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                            }
                            inboxFolderEntryId = session.Mailbox.MapiStore.GetInboxFolderEntryId();
                        }
                        catch (MapiPermanentException ex)
                        {
                            throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenFolder, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                            {
                                string.Format("DefaultFolderManager::GetInboxId. Hit exception when adding ``free'' default folders.", new object[0]),
                                ex
                            });
                        }
                        catch (MapiRetryableException ex2)
                        {
                            throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenFolder, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                            {
                                string.Format("DefaultFolderManager::GetInboxId. Hit exception when adding ``free'' default folders.", new object[0]),
                                ex2
                            });
                        }
                        finally
                        {
                            try
                            {
                                if (session != null)
                                {
                                    session.EndMapiCall();
                                    if (flag)
                                    {
                                        session.EndServerHealthCall();
                                    }
                                }
                            }
                            finally
                            {
                                if (StorageGlobals.MapiTestHookAfterCall != null)
                                {
                                    StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                                }
                            }
                        }
                        if (IdConverter.IsFolderId(inboxFolderEntryId))
                        {
                            StoreObjectId inboxId = StoreObjectId.FromProviderSpecificId(inboxFolderEntryId);
                            DefaultFolderManager.TryGetDefaultFolderCulture(session, inboxId, out stampedCulture, out inboxDisplayName);
                        }
                    }
                    defaultFolderContext.Session.SharedDataManager.DefaultFoldersCulture = defaultFolderManager.GetBestCulture(stampedCulture, inboxDisplayName, session);
                }
                else
                {
                    defaultFolderContext.Session.SharedDataManager.DefaultFoldersCulture = CultureInfo.InvariantCulture;
                }
                defaultFolderManager.CacheDefaultFolders(defaultFolderContext, foldersToInit);
                defaultFolderManager.ValidateDefaultFolderSet(defaultFolderContext);
            }
            finally
            {
                defaultFolderContext.DoneDefaultFolderInitialization();
            }
            return(defaultFolderManager);
        }
コード例 #21
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
        public static byte[] GetParentEntryIdFromMessageEntryId(byte[] messageEntryId)
        {
            Util.ThrowOnNullArgument(messageEntryId, "messageEntryId");
            if (!IdConverter.IsMessageId(messageEntryId))
            {
                throw new ArgumentException(ServerStrings.ExOnlyMessagesHaveParent);
            }
            StoreSession storeSession = null;
            object       thisObject   = null;
            bool         flag         = false;

            byte[] folderEntryIdFromMessageEntryId;
            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                try
                {
                    folderEntryIdFromMessageEntryId = MapiStore.GetFolderEntryIdFromMessageEntryId(messageEntryId);
                }
                catch (MapiExceptionInvalidEntryId innerException)
                {
                    throw new ArgumentException("Id is invalid.", innerException);
                }
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetParentEntryId, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Unable to get the parent entry id for the message.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetParentEntryId, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Unable to get the parent entry id for the message.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(folderEntryIdFromMessageEntryId);
        }
コード例 #22
0
 protected override bool IsCompatibleId(StoreId id, ICoreObject coreObject)
 {
     return((coreObject == null || coreObject is CoreFolder) && IdConverter.IsFolderId(StoreId.GetStoreObjectId(id)));
 }
コード例 #23
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
 public static StoreObjectId GetParentIdFromMessageId(StoreObjectId messageId)
 {
     Util.ThrowOnNullArgument(messageId, "messageId");
     return(StoreObjectId.FromProviderSpecificId(IdConverter.GetParentEntryIdFromMessageEntryId(messageId.ProviderLevelItemId)));
 }
コード例 #24
0
        public void GroupOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId destinationFolderId, StoreObjectId[] itemIds, GroupOperationResult result, bool onBeforeNotification, CallbackContext callbackContext)
        {
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
            Util.ThrowOnNullArgument(dumpster, "dumpster");
            if (itemIds == null)
            {
                return;
            }
            if (dumpster.IsDumpsterOverCalendarLoggingQuota(callbackContext.SessionWithBestAccess, settings))
            {
                ExTraceGlobals.CalendarLoggingTracer.Information <string, string>((long)sourceSession.GetHashCode(), "User {0} has exceeded the calendar logging quota of {1}", sourceSession.UserLegacyDN, settings.CalendarLoggingQuota.Value.ToString("A"));
                StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_COWCalendarLoggingStopped, sourceSession.UserLegacyDN, new object[]
                {
                    sourceSession.UserLegacyDN
                });
                return;
            }
            if (dumpster.IsDumpsterOverWarningQuota(settings))
            {
                ExTraceGlobals.CalendarLoggingTracer.Information <string, string>((long)sourceSession.GetHashCode(), "Disabling calendar logging for user {0}, since it has exceeded the dumpster warning quota of {1}", sourceSession.UserLegacyDN, settings.DumpsterWarningQuota.Value.ToString("A"));
                dumpster.DisableCalendarLogging();
                return;
            }
            foreach (StoreObjectId storeObjectId in itemIds)
            {
                ICoreItem coreItem           = null;
                StoragePermanentException ex = null;
                try
                {
                    if (CalendarLoggingHelper.ShouldBeCopiedOnWrite(storeObjectId))
                    {
                        if (CalendarLoggingHelper.ShouldLogInitialCheck(storeObjectId, operation))
                        {
                            try
                            {
                                coreItem = CoreItem.Bind(callbackContext.SessionWithBestAccess, storeObjectId, CalendarLoggingHelper.RequiredOriginalProperties);
                                if (!CalendarLoggingHelper.ShouldLog(coreItem, operation))
                                {
                                    goto IL_25A;
                                }
                                if (coreItem.PropertyBag.GetValueOrDefault <bool>(InternalSchema.HasBeenSubmitted))
                                {
                                    ExTraceGlobals.CalendarLoggingTracer.TraceWarning <ICoreItem, COWTriggerAction>((long)callbackContext.SessionWithBestAccess.GetHashCode(), "Save Item for Calendar Logging skipped as the item.HasBeenSubmitted is true (item {0}, operation {1}.", coreItem, operation);
                                    goto IL_25A;
                                }
                                switch (operation)
                                {
                                case COWTriggerAction.Move:
                                case COWTriggerAction.MoveToDeletedItems:
                                case COWTriggerAction.SoftDelete:
                                    if (!this.PerformFolderCopyOnWrite(settings, dumpster, coreItem, callbackContext.SessionWithBestAccess, operation, flags, false))
                                    {
                                        goto IL_25A;
                                    }
                                    break;

                                case COWTriggerAction.HardDelete:
                                {
                                    StoreObjectId parentIdFromMessageId = IdConverter.GetParentIdFromMessageId(storeObjectId);
                                    if (DumpsterFolderHelper.IsAuditFolder(callbackContext.SessionWithBestAccess, parentIdFromMessageId))
                                    {
                                        goto IL_25A;
                                    }
                                    if (DumpsterFolderHelper.IsDumpsterFolder(callbackContext.SessionWithBestAccess, parentIdFromMessageId))
                                    {
                                        this.PerformCopyOnWrite(callbackContext.SessionWithBestAccess, dumpster, storeObjectId);
                                        goto IL_25A;
                                    }
                                    if (!this.PerformFolderCopyOnWrite(settings, dumpster, coreItem, callbackContext.SessionWithBestAccess, operation, flags, !settings.HoldEnabled()))
                                    {
                                        goto IL_25A;
                                    }
                                    break;
                                }
                                }
                            }
                            catch (ObjectNotFoundException ex2)
                            {
                                ex = ex2;
                            }
                            catch (VirusDetectedException ex3)
                            {
                                ex = ex3;
                            }
                            catch (VirusMessageDeletedException ex4)
                            {
                                ex = ex4;
                            }
                            catch (VirusException ex5)
                            {
                                ex = ex5;
                            }
                            if (ex != null)
                            {
                                ExTraceGlobals.CalendarLoggingTracer.TraceWarning <StoreObjectId, StoragePermanentException, COWTriggerAction>((long)callbackContext.SessionWithBestAccess.GetHashCode(), "Item ({0}) processing for Calendar Logging failure {1} (operation {2}).", storeObjectId, ex, operation);
                            }
                        }
                    }
                }
                finally
                {
                    if (coreItem != null)
                    {
                        coreItem.Dispose();
                    }
                }
                IL_25A :;
            }
        }
コード例 #25
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
 public static bool IsFromPublicStore(StoreObjectId id)
 {
     Util.ThrowOnNullArgument(id, "id");
     return(IdConverter.IsFromPublicStore(id.ProviderLevelItemId));
 }
コード例 #26
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
        public long GetMidFromMessageId(StoreObjectId messageStoreObjectId)
        {
            Util.ThrowOnNullArgument(messageStoreObjectId, "messageStoreObjectId");
            if (!IdConverter.IsMessageId(messageStoreObjectId))
            {
                throw new ArgumentException("The argument messageStoreObjectId is not an id of a message.");
            }
            StoreSession storeSession = this.session;
            bool         flag         = false;
            long         midFromMessageEntryId;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                try
                {
                    midFromMessageEntryId = this.session.Mailbox.MapiStore.GetMidFromMessageEntryId(messageStoreObjectId.ProviderLevelItemId);
                }
                catch (MapiExceptionInvalidEntryId innerException)
                {
                    throw new CorruptDataException(ServerStrings.MapiInvalidId, innerException);
                }
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiErrorParsingId, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Unable to get the MID from the entry ID.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiErrorParsingId, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Unable to get the MID from the entry ID.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(midFromMessageEntryId);
        }
コード例 #27
0
        public static Participant[] ExpandDeep(StoreSession storeSession, StoreObjectId distributionListId, bool shouldAddNonExistPDL)
        {
            Dictionary <StoreObjectId, Participant> dictionary = new Dictionary <StoreObjectId, Participant>();
            Queue <StoreObjectId> queue = new Queue <StoreObjectId>();
            List <Participant>    list  = new List <Participant>();

            queue.Enqueue(distributionListId);
            while (queue.Count > 0)
            {
                StoreObjectId    storeObjectId    = queue.Dequeue();
                DistributionList distributionList = null;
                try
                {
                    distributionList = DistributionList.Bind(storeSession, storeObjectId);
                }
                catch (ObjectNotFoundException arg)
                {
                    if (storeSession.ItemBinder != null)
                    {
                        Item item = storeSession.ItemBinder.BindItem(storeObjectId, IdConverter.IsFromPublicStore(storeObjectId), IdConverter.GetParentIdFromMessageId(storeObjectId));
                        distributionList = (item as DistributionList);
                        if (item != null && distributionList == null)
                        {
                            item.Dispose();
                        }
                    }
                    if (distributionList == null)
                    {
                        ExTraceGlobals.StorageTracer.TraceDebug <ObjectNotFoundException>(0L, "DistributionList::ExpandDeep. A PDL member in PDL doesn't exist. Ignore it and continue to expand other members. Exception = {0}.", arg);
                        if (shouldAddNonExistPDL && dictionary.ContainsKey(storeObjectId))
                        {
                            list.Add(new Participant(dictionary[storeObjectId].DisplayName, null, "MAPIPDL"));
                        }
                    }
                }
                if (distributionList != null)
                {
                    using (distributionList)
                    {
                        foreach (DistributionListMember distributionListMember in distributionList)
                        {
                            if (!(distributionListMember.Participant == null))
                            {
                                if (distributionListMember.IsDistributionList() == true && distributionListMember.Participant.Origin is StoreParticipantOrigin && distributionListMember.Participant.ValidationStatus == ParticipantValidationStatus.NoError)
                                {
                                    StoreObjectId originItemId = ((StoreParticipantOrigin)distributionListMember.Participant.Origin).OriginItemId;
                                    if (!dictionary.ContainsKey(originItemId) && !originItemId.Equals(distributionListId))
                                    {
                                        queue.Enqueue(originItemId);
                                        dictionary.Add(originItemId, distributionListMember.Participant);
                                    }
                                }
                                else
                                {
                                    list.Add(distributionListMember.Participant);
                                }
                            }
                        }
                    }
                }
            }
            return(list.ToArray());
        }
コード例 #28
0
        internal static CalendarGroupEntryInfo GetCalendarGroupEntryInfoFromRow(IStorePropertyBag row)
        {
            VersionedId versionedId = (VersionedId)row.TryGetProperty(ItemSchema.Id);

            byte[] valueOrDefault  = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.NodeEntryId, null);
            byte[] valueOrDefault2 = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.ParentGroupClassId, null);
            string valueOrDefault3 = row.GetValueOrDefault <string>(ItemSchema.Subject, string.Empty);
            LegacyCalendarColor valueOrDefault4 = row.GetValueOrDefault <LegacyCalendarColor>(CalendarGroupEntrySchema.CalendarColor, LegacyCalendarColor.Auto);

            byte[]              valueOrDefault5  = row.GetValueOrDefault <byte[]>(FolderTreeDataSchema.Ordinal, null);
            byte[]              valueOrDefault6  = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.SharerAddressBookEntryId, null);
            byte[]              valueOrDefault7  = row.GetValueOrDefault <byte[]>(CalendarGroupEntrySchema.StoreEntryId, null);
            ExDateTime          valueOrDefault8  = row.GetValueOrDefault <ExDateTime>(StoreObjectSchema.LastModifiedTime, ExDateTime.MinValue);
            FolderTreeDataType  valueOrDefault9  = row.GetValueOrDefault <FolderTreeDataType>(FolderTreeDataSchema.Type, FolderTreeDataType.NormalFolder);
            FolderTreeDataFlags valueOrDefault10 = row.GetValueOrDefault <FolderTreeDataFlags>(FolderTreeDataSchema.FolderTreeDataFlags, FolderTreeDataFlags.None);
            Guid safeGuidFromByteArray           = FolderTreeData.GetSafeGuidFromByteArray(valueOrDefault2);

            if (safeGuidFromByteArray.Equals(Guid.Empty))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <int>(0L, "Found CalendarGroupEntry with invalid parent group class id. ArrayLength: {0}", (valueOrDefault2 == null) ? -1 : valueOrDefault2.Length);
                return(null);
            }
            if (valueOrDefault9 != FolderTreeDataType.SharedFolder)
            {
                if (IdConverter.IsFolderId(valueOrDefault))
                {
                    StoreObjectId storeObjectId = StoreObjectId.FromProviderSpecificId(valueOrDefault);
                    if ((valueOrDefault10 & FolderTreeDataFlags.IsDefaultStore) == FolderTreeDataFlags.IsDefaultStore)
                    {
                        return(new LocalCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId, valueOrDefault5, safeGuidFromByteArray, (valueOrDefault10 & FolderTreeDataFlags.ICalFolder) == FolderTreeDataFlags.ICalFolder || (valueOrDefault10 & FolderTreeDataFlags.SharedIn) == FolderTreeDataFlags.SharedIn, valueOrDefault8));
                    }
                    if ((valueOrDefault10 & FolderTreeDataFlags.PublicFolder) == FolderTreeDataFlags.PublicFolder)
                    {
                        string calendarOwner = Microsoft.Exchange.Data.Storage.StoreEntryId.TryParseStoreEntryIdMailboxDN(valueOrDefault7);
                        storeObjectId = StoreObjectId.FromLegacyFavoritePublicFolderId(storeObjectId);
                        return(new LinkedCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId, calendarOwner, safeGuidFromByteArray, valueOrDefault5, false, true, valueOrDefault8));
                    }
                    ExTraceGlobals.StorageTracer.TraceDebug <StoreObjectType, string, VersionedId>(0L, "Found CalendarGroupEntry of type {0} referencing a non-calendar folder. ObjectType: {0}. CalendarName: {1}. Id: {2}.", storeObjectId.ObjectType, valueOrDefault3, versionedId);
                }
                return(null);
            }
            bool   flag = true;
            Eidt   eidt;
            string text;

            if (!AddressBookEntryId.IsAddressBookEntryId(valueOrDefault6, out eidt, out text))
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "AddressBookEntryId is missing, not primary calendar {0}", valueOrDefault3);
                if (valueOrDefault7 == null)
                {
                    ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "StoreEntryId is missing for calendar: {0} - invalid entry, skipping.", valueOrDefault3);
                    return(null);
                }
                text = Microsoft.Exchange.Data.Storage.StoreEntryId.TryParseStoreEntryIdMailboxDN(valueOrDefault7);
                flag = false;
            }
            if (text == null)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Unable to determine owner of shared calendar: {0}. Skipping.", valueOrDefault3);
                return(null);
            }
            StoreObjectId storeObjectId2 = IdConverter.IsFolderId(valueOrDefault) ? StoreObjectId.FromProviderSpecificId(valueOrDefault) : null;

            if (!flag && storeObjectId2 == null)
            {
                ExTraceGlobals.StorageTracer.TraceDebug <string>(0L, "Secondary shared calendar without a folder id encountered {0}. Skipping.", valueOrDefault3);
                return(null);
            }
            return(new LinkedCalendarGroupEntryInfo(valueOrDefault3, versionedId, valueOrDefault4, storeObjectId2, text, safeGuidFromByteArray, valueOrDefault5, flag, false, valueOrDefault8));
        }
コード例 #29
0
 protected override bool IsCompatibleId(StoreId id, ICoreObject coreObject)
 {
     return((coreObject == null || coreObject is ICoreItem) && IdConverter.IsMessageId(StoreId.GetStoreObjectId(id)));
 }
コード例 #30
0
ファイル: IdConverter.cs プロジェクト: YHZX2013/exchange_diff
 public static GuidGlobCount GuidGlobCountFromEntryId(byte[] entryId)
 {
     return(IdConverter.ExtractGuidGlobCountFromEntryId(entryId, 22));
 }