Beispiel #1
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);
        }
Beispiel #2
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);
 }
 public string GetItemInAllItemsFolderPath()
 {
     if (this.allItemsItemId == null)
     {
         return(string.Empty);
     }
     return(AnalysisGroupData.GetFolderPathForFolderId(this.parent.MailboxSession, IdConverter.GetParentIdFromMessageId(this.allItemsItemId)));
 }
Beispiel #4
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 :;
            }
        }
Beispiel #5
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());
        }