Ejemplo n.º 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");
     Util.ThrowOnNullArgument(settings, "settings");
     Util.ThrowOnNullArgument(sourceSession, "sourceSession");
     Util.ThrowOnNullArgument(dumpster, "dumpster");
     if (onDumpster)
     {
         ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since the operation is on dumpster", sourceSession.UserLegacyDN);
         return(CowClientOperationSensitivity.Skip);
     }
     if (!onBeforeNotification)
     {
         ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since we are only interested in on-before notifications", sourceSession.UserLegacyDN);
         return(CowClientOperationSensitivity.Skip);
     }
     if (!CalendarLoggingHelper.ShouldLog(operation))
     {
         ExTraceGlobals.CalendarLoggingTracer.Information <string, COWTriggerAction>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since the trigger action {1} is not interesting", sourceSession.UserLegacyDN, operation);
         return(CowClientOperationSensitivity.Skip);
     }
     if (DumpsterFolderHelper.IsAuditFolder(callbackContext.SessionWithBestAccess, sourceFolderId))
     {
         ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since the operation is on audit folder", sourceSession.UserLegacyDN);
         return(CowClientOperationSensitivity.Skip);
     }
     if (!settings.IsCalendarLoggingEnabled())
     {
         ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since calendar logging is disabled for this user", sourceSession.UserLegacyDN);
         return(CowClientOperationSensitivity.Skip);
     }
     if (!DumpsterFolderHelper.IsDumpsterFolder(callbackContext.SessionWithBestAccess, sourceFolderId))
     {
         return(CowClientOperationSensitivity.Capture);
     }
     if (operation == COWTriggerAction.HardDelete && !sourceFolderId.Equals(dumpster.CalendarLoggingFolderId))
     {
         return(CowClientOperationSensitivity.Capture);
     }
     ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)sourceSession.GetHashCode(), "Skipping calendar COW group operation for user {0}, since we are not interested in hard deletes in calendar logging folder", sourceSession.UserLegacyDN);
     return(CowClientOperationSensitivity.Skip);
 }
Ejemplo n.º 2
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");
     return(CowClientOperationSensitivity.Skip);
 }
Ejemplo n.º 3
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)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            Util.ThrowOnNullArgument(callbackContext, "callbackContext");
            if (!WorkingSetPublisher.IsGroupWSPublishingEnabled())
            {
                COWGroupMessageWSPublishing.Tracer.Information((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping group message working set publishing as the feature is disabled.");
                return(true);
            }
            switch (callbackContext.COWGroupMessageWSPublishingState)
            {
            case COWProcessorState.Unknown:
                callbackContext.COWGroupMessageWSPublishingState = this.InspectNotification(operation, session, item, onBeforeNotification, onDumpster);
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId, COWProcessorState>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: inspected item {0} and result is {1}.", itemId, callbackContext.COWGroupMessageWSPublishingState);
                return(true);

            case COWProcessorState.DoNotProcess:
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping notification for item {0} because it should not be processed.", itemId);
                return(true);

            case COWProcessorState.ProcessAfterSave:
                return(onBeforeNotification);

            case COWProcessorState.Processed:
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.SkipItemOperation: skipping notification for item {0} because it has already been processed.", itemId);
                return(true);

            default:
                return(true);
            }
        }
Ejemplo n.º 4
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            Util.ThrowOnNullArgument(item, "item");
            MailboxSession mailboxSession = session as MailboxSession;
            ExDateTime     now            = ExDateTime.Now;

            try
            {
                item.PropertyBag.Load(COWSiteMailboxMessageDedup.PropsForMessageRemoval);
                if (item.Id != null && item.Id.ObjectId != null)
                {
                    StoreObjectId storeObjectId = item.PropertyBag.TryGetProperty(StoreObjectSchema.ParentItemId) as StoreObjectId;
                    if (storeObjectId != null)
                    {
                        using (CoreFolder coreFolder = CoreFolder.Bind(session, storeObjectId))
                        {
                            DeleteItemFlags deleteItemFlags = DeleteItemFlags.HardDelete | DeleteItemFlags.SuppressReadReceipt;
                            coreFolder.DeleteItems(deleteItemFlags, new StoreObjectId[]
                            {
                                item.Id.ObjectId
                            });
                        }
                        COWSiteMailboxMessageDedup.Tracer.TraceDebug <StoreObjectId, string, double>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.ItemOperation: deleting message {0} from site mailbox {1} used {2} milliseconds", itemId, mailboxSession.DisplayName, (ExDateTime.Now - now).TotalMilliseconds);
                    }
                }
            }
            catch (StoragePermanentException arg)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.ItemOperation: got store permanent exception: {0}", arg);
            }
            catch (StorageTransientException arg2)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.ItemOperation: got store transient exception: {0}", arg2);
            }
            callbackContext.SiteMailboxMessageDedupState = COWProcessorState.Processed;
        }
Ejemplo n.º 5
0
 public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
 {
     EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
     EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
     EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
 }
Ejemplo n.º 6
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");
     return(true);
 }
Ejemplo n.º 7
0
 public bool OnBeforeFolderChange(FolderChangeOperation operation, FolderChangeOperationFlags flags, StoreSession sourceSession, StoreSession destinationSession, StoreObjectId sourceFolderId, StoreObjectId destinationFolderId, ICollection <StoreObjectId> itemIds, CallbackContext callbackContext)
 {
     PublicFolderCOWSession.< > c__DisplayClass4 CS$ < > 8__locals1 = new PublicFolderCOWSession.< > c__DisplayClass4();
     CS$ < > 8__locals1.sourceSession  = sourceSession;
     CS$ < > 8__locals1.sourceFolderId = sourceFolderId;
     CS$ < > 8__locals1.< > 4__this    = this;
     this.CheckDisposed("OnBeforeFolderChange");
     EnumValidator.ThrowIfInvalid <FolderChangeOperation>(operation, "operation");
     EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
     Util.ThrowOnNullArgument(callbackContext, "callbackContext");
     if (this.InCallback)
     {
         return(false);
     }
     base.Results    = new COWResults(this.publicFolderSession, itemIds);
     this.InCallback = true;
     try
     {
         PublicFolderCOWSession.< > c__DisplayClass7 CS$ < > 8__locals2 = new PublicFolderCOWSession.< > c__DisplayClass7();
         CS$ < > 8__locals2.CS$ < > 8__locals5 = CS$ < > 8__locals1;
         CS$ < > 8__locals2.action             = COWSessionBase.GetTriggerAction(operation);
         if (itemIds.Count == 0 || !COWSessionBase.IsDeleteOperation(CS$ < > 8__locals2.action))
         {
             ExTraceGlobals.SessionTracer.TraceDebug <FolderChangeOperation, int>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - Skipping operation {0} for {1} items", operation, itemIds.Count);
             return(false);
         }
         CS$ < > 8__locals2.messagesToSoftDelete = new List <StoreObjectId>(itemIds.Count);
         List <StoreObjectId> list = new List <StoreObjectId>(itemIds.Count);
         CS$ < > 8__locals2.messageIds = COWSessionBase.InternalFilterItems(itemIds);
         foreach (StoreObjectId storeObjectId in COWSessionBase.InternalFilterFolders(itemIds))
         {
             bool flag = CS$ < > 8__locals1.sourceFolderId != null && storeObjectId.Equals(CS$ < > 8__locals1.sourceFolderId);
             if (flag)
             {
                 ExTraceGlobals.SessionTracer.TraceError <StoreObjectId>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - Folder {0} skipped. We currently don't support EmptyFolder operation for public folders", storeObjectId);
                 base.Results.AddResult(new GroupOperationResult(OperationResult.PartiallySucceeded, new StoreObjectId[]
                 {
                     storeObjectId
                 }, new StoragePermanentException(ServerStrings.ErrorEmptyFolderNotSupported)));
             }
             else
             {
                 list.Add(storeObjectId);
             }
         }
         if (CS$ < > 8__locals2.messageIds.Count > 0 && (flags & FolderChangeOperationFlags.IncludeItems) == FolderChangeOperationFlags.IncludeItems)
         {
             Util.ThrowOnNullArgument(CS$ < > 8__locals1.sourceFolderId, "sourceFolderId");
             ExTraceGlobals.SessionTracer.TraceDebug <COWTriggerAction, int, StoreObjectId>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - Processing action {0} for {1} messages in folder {2}", CS$ < > 8__locals2.action, CS$ < > 8__locals2.messageIds.Count, CS$ < > 8__locals1.sourceFolderId);
             if (CS$ < > 8__locals2.action == COWTriggerAction.HardDelete)
             {
                 if (CS$ < > 8__locals2.messageIds.Count == itemIds.Count)
                 {
                     ExTraceGlobals.SessionTracer.TraceDebug <int>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - Skipping hard delete for all {0} messages", CS$ < > 8__locals2.messageIds.Count);
                     return(false);
                 }
                 this.Execute(delegate()
                 {
                     using (Folder folder = Folder.Bind(CS$ < > 8__locals2.CS$ < > 8__locals5.sourceSession, CS$ < > 8__locals2.CS$ < > 8__locals5.sourceFolderId))
                     {
                         CS$ < > 8__locals2.CS$ < > 8__locals5.< > 4__this.Results.AddResult(folder.InternalDeleteItems(DeleteItemFlags.HardDelete | DeleteItemFlags.SuppressReadReceipt, CS$ < > 8__locals2.messageIds.ToArray()));
                     }
                 }, CS$ < > 8__locals2.messageIds);
             }
             else
             {
                 List <StoreObjectId> messagesFailed = new List <StoreObjectId>(CS$ < > 8__locals2.messageIds.Count);
                 using (List <StoreObjectId> .Enumerator enumerator2 = CS$ < > 8__locals2.messageIds.GetEnumerator())
                 {
                     while (enumerator2.MoveNext())
                     {
                         StoreObjectId itemId = enumerator2.Current;
                         if (itemId is OccurrenceStoreObjectId)
                         {
                             ExTraceGlobals.SessionTracer.TraceDebug <StoreObjectId>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - Skipping item {0} since it is an OccurrenceStoreObjectId", itemId);
                         }
                         else
                         {
                             this.Execute(delegate()
                             {
                                 using (Item item = Item.Bind(CS$ < > 8__locals1.< > 4__this.publicFolderSession, itemId, PublicFolderCOWSession.propertiesToLoadForItems))
                                 {
                                     if ((item.PropertyBag.GetValueOrDefault <EffectiveRights>(StoreObjectSchema.EffectiveRights, EffectiveRights.None) & EffectiveRights.Delete) == EffectiveRights.None)
                                     {
                                         ExTraceGlobals.SessionTracer.TraceError <StoreObjectId>((long)CS$ < > 8__locals1.< > 4__this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - User does not have delete permission for message id {0}", itemId);
                                         messagesFailed.Add(itemId);
                                     }
                                     else
                                     {
                                         CS$ < > 8__locals2.messagesToSoftDelete.Add(itemId);
                                     }
                                 }
                             }, itemId);
                         }
                     }
                 }
                 if (messagesFailed.Count > 0)
                 {
                     ExTraceGlobals.SessionTracer.TraceError <int>((long)this.StoreSession.GetHashCode(), "PublicFolderCOWSession::OnBeforeFolderChange - {0} messages skipped due to insufficient permissions", messagesFailed.Count);
                     base.Results.AddResult(new GroupOperationResult(OperationResult.PartiallySucceeded, messagesFailed, new AccessDeniedException(ServerStrings.NotEnoughPermissionsToPerformOperation)));
                 }
             }
         }
Ejemplo n.º 8
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)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            switch (callbackContext.ContactLinkingProcessingState)
            {
            case ContactLinkingProcessingState.DoNotProcess:
                COWContactLinking.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWContactLinking.SkipItemOperation: skipping notification for item {0} because it should not be processed.", itemId);
                return(true);

            case ContactLinkingProcessingState.ProcessBeforeSave:
                return(!onBeforeNotification || state != COWTriggerActionState.Flush);

            case ContactLinkingProcessingState.ProcessAfterSave:
                return(onBeforeNotification);

            case ContactLinkingProcessingState.Processed:
                COWContactLinking.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWContactLinking.SkipItemOperation: skipping notification for item {0} because it has already been processed.", itemId);
                return(true);
            }
            callbackContext.ContactLinkingProcessingState = this.InspectNotification(operation, session, item, onBeforeNotification, onDumpster);
            COWContactLinking.Tracer.TraceDebug <StoreObjectId, ContactLinkingProcessingState>((long)this.GetHashCode(), "COWContactLinking.SkipItemOperation: inspected item {0} and result is {1}.", itemId, callbackContext.ContactLinkingProcessingState);
            return(callbackContext.ContactLinkingProcessingState != ContactLinkingProcessingState.ProcessBeforeSave || !onBeforeNotification || state != COWTriggerActionState.Flush);
        }
Ejemplo n.º 9
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(item, "item");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            COWContactLinking.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWContactLinking.ItemOperation: processing contact linking for item {0}.", itemId);
            MailboxSession                   mailboxSession                = (MailboxSession)session;
            MailboxInfoForLinking            mailboxInfo                   = MailboxInfoForLinking.CreateFromMailboxSession(mailboxSession);
            ContactLinkingPerformanceTracker performanceTracker            = new ContactLinkingPerformanceTracker(mailboxSession);
            DirectoryPersonSearcher          directoryPersonSearcher       = new DirectoryPersonSearcher(mailboxSession.MailboxOwner);
            ContactStoreForContactLinking    contactStoreForContactLinking = new ContactStoreForCowContactLinking(mailboxSession, performanceTracker);
            ContactLinkingLogger             logger = new ContactLinkingLogger("COWContactLinking", mailboxInfo);
            AutomaticLink automaticLink             = new AutomaticLink(mailboxInfo, logger, performanceTracker, directoryPersonSearcher, contactStoreForContactLinking);

            automaticLink.LinkNewOrUpdatedContactBeforeSave(item, new Func <ContactInfoForLinking, IContactStoreForContactLinking, IEnumerable <ContactInfoForLinking> >(this.GetOtherContactsEnumeratorForCOW));
            if (!onBeforeNotification)
            {
                item.SaveFlags |= PropertyBagSaveFlags.ForceNotificationPublish;
                try
                {
                    item.Save(SaveMode.NoConflictResolution);
                }
                finally
                {
                    item.SaveFlags &= ~PropertyBagSaveFlags.ForceNotificationPublish;
                }
            }
            callbackContext.ContactLinkingProcessingState = ContactLinkingProcessingState.Processed;
        }
Ejemplo n.º 10
0
 ConflictResolutionResult ICoreItem.InternalFlush(SaveMode saveMode, CoreItemOperation operation, CallbackContext callbackContext)
 {
     return(this.CoreItem.InternalFlush(saveMode, operation, callbackContext));
 }
Ejemplo n.º 11
0
 ConflictResolutionResult ICoreItem.InternalSave(SaveMode saveMode, CallbackContext callbackContext)
 {
     return(this.CoreItem.InternalSave(saveMode, callbackContext));
 }
Ejemplo n.º 12
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(dumpster, "dumpster");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            MailboxSession sessionWithBestAccess = callbackContext.SessionWithBestAccess;

            if (onBeforeNotification)
            {
                if (CalendarLoggingHelper.ShouldLog(item, operation))
                {
                    StoreObjectId storeObjectId = ((ICoreObject)item).StoreObjectId;
                    CalendarLoggingHelper.AddMetadata(item, operation, null);
                    if (operation == COWTriggerAction.Update && state == COWTriggerActionState.Save && CalendarLoggingHelper.ShouldBeCopiedOnWrite(storeObjectId))
                    {
                        if (settings.HoldEnabled() && item.IsLegallyDirty)
                        {
                            return;
                        }
                        if (!settings.IsCurrentFolderItemEnabled(sessionWithBestAccess, item) && !COWCalendarLogging.IsParkedMessagesFolder(settings, sessionWithBestAccess))
                        {
                            return;
                        }
                        if (dumpster.IsDumpsterOverCalendarLoggingQuota(sessionWithBestAccess, settings))
                        {
                            ExTraceGlobals.CalendarLoggingTracer.Information <string, string>((long)session.GetHashCode(), "User {0} has exceeded the calendar logging quota of {1}", session.UserLegacyDN, settings.CalendarLoggingQuota.Value.ToString("A"));
                            StorageGlobals.EventLogger.LogEvent(StorageEventLogConstants.Tuple_COWCalendarLoggingStopped, session.UserLegacyDN, new object[]
                            {
                                session.UserLegacyDN
                            });
                        }
                        else if (dumpster.IsDumpsterOverWarningQuota(settings))
                        {
                            ExTraceGlobals.CalendarLoggingTracer.Information <string, string>((long)session.GetHashCode(), "Disabling calendar logging for user {0}, since it has exceeded the dumpster warning quota of {1}", session.UserLegacyDN, settings.DumpsterWarningQuota.Value.ToString("A"));
                            dumpster.DisableCalendarLogging();
                        }
                        else
                        {
                            StoreObjectId calendarLogGeneratedId = this.PerformCopyOnWrite(sessionWithBestAccess, dumpster, storeObjectId);
                            dumpster.Results.CalendarLogGeneratedId = calendarLogGeneratedId;
                        }
                    }
                    COWSettings.AddMetadata(settings, item, operation);
                    return;
                }
            }
            else if (operation == COWTriggerAction.Update && state == COWTriggerActionState.Save && result == OperationResult.Failed)
            {
                dumpster.RollbackItemVersion(sessionWithBestAccess, item, dumpster.Results.CalendarLogGeneratedId);
                dumpster.Results.CalendarLogGeneratedId = null;
            }
        }
Ejemplo n.º 13
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 :;
            }
        }
Ejemplo n.º 14
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)
 {
     Util.ThrowOnNullArgument(settings, "settings");
     Util.ThrowOnNullArgument(session, "session");
     Util.ThrowOnNullArgument(dumpster, "dumpster");
     EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
     EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
     if (onDumpster)
     {
         ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)session.GetHashCode(), "Skipping calendar COW item operation for user {0}, since the operation is on dumpster", session.UserLegacyDN);
         return(true);
     }
     if (!CalendarLoggingHelper.ShouldLog(operation))
     {
         ExTraceGlobals.CalendarLoggingTracer.Information <string, COWTriggerAction>((long)session.GetHashCode(), "Skipping calendar COW item operation for user {0}, since the trigger action {1} is not interesting", session.UserLegacyDN, operation);
         return(true);
     }
     if (!onBeforeNotification && operation != COWTriggerAction.Update)
     {
         ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)session.GetHashCode(), "Skipping calendar COW item operation for user {0}, since we are only interested in on-before notifications and update trigger actions", session.UserLegacyDN);
         return(true);
     }
     if (COWSettings.IsImapPoisonMessage(onBeforeNotification, operation, session, item))
     {
         ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)session.GetHashCode(), "Skipping calendar COW item operation for user {0}, since the items is marked as IMAP poison message", session.UserLegacyDN);
         return(true);
     }
     if (!settings.IsCalendarLoggingEnabled())
     {
         ExTraceGlobals.CalendarLoggingTracer.Information <string>((long)session.GetHashCode(), "Skipping calendar COW item operation for user {0}, since calendar logging is disabled for this user", session.UserLegacyDN);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 15
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");
            int num = 0;

            if (itemIds != null)
            {
                foreach (StoreObjectId storeObjectId in itemIds)
                {
                    if (!(storeObjectId is OccurrenceStoreObjectId))
                    {
                        num++;
                    }
                }
            }
            if (itemIds == null || num == itemIds.Length)
            {
                dumpster.MoveItemsToDumpster(callbackContext.SessionWithBestAccess, dumpster.RecoverableItemsDeletionsFolderId, itemIds);
                return;
            }
            if (num > 0)
            {
                StoreObjectId[] array = new StoreObjectId[num];
                num = 0;
                foreach (StoreObjectId storeObjectId2 in itemIds)
                {
                    if (!(storeObjectId2 is OccurrenceStoreObjectId))
                    {
                        array[num] = storeObjectId2;
                        num++;
                    }
                }
                dumpster.MoveItemsToDumpster(callbackContext.SessionWithBestAccess, dumpster.RecoverableItemsDeletionsFolderId, array);
            }
        }
Ejemplo n.º 16
0
        public void UpdateHistory(CallbackContext callbackContext)
        {
            if (this.ShouldSkipAudit)
            {
                return;
            }
            MailboxSession mailboxSession = (MailboxSession)this.currentFolder.Session;
            CoreFolder     coreFolder     = null;
            StoreObjectId  objectId       = this.currentFolder.Id.ObjectId;

            if (mailboxSession.LogonType == LogonType.Delegated || mailboxSession.LogonType == LogonType.DelegatedAdmin)
            {
                Exception ex = null;
                try
                {
                    coreFolder         = CoreFolder.Bind(callbackContext.SessionWithBestAccess, objectId);
                    this.currentFolder = coreFolder;
                }
                catch (StoragePermanentException ex2)
                {
                    ex = ex2;
                }
                catch (StorageTransientException ex3)
                {
                    ex = ex3;
                }
                if (ex != null)
                {
                    ExTraceGlobals.SessionTracer.TraceWarning <StoreObjectId, Exception>((long)this.currentFolder.Session.GetHashCode(), "Failed to rebind folder {0} with Admin logon. The cached RecentBindingHistory data will not be updated. Error: {1}", objectId, ex);
                    ProcessInfoEventLogger.Log(StorageEventLogConstants.Tuple_ErrorBindingFolderForFolderBindHistory, objectId.ToString(), new object[]
                    {
                        objectId,
                        mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                        mailboxSession.MailboxGuid,
                        mailboxSession.LogonType,
                        IdentityHelper.SidFromLogonIdentity(mailboxSession.Identity),
                        COWTriggerAction.FolderBind,
                        ex
                    });
                    this.currentFolder = null;
                }
            }
            if (this.currentFolder != null)
            {
                try
                {
                    this.currentFolder.PropertyBag.SetProperty(FolderSchema.RecentBindingHistory, this.bindingHistory.ToArray());
                    FolderSaveResult folderSaveResult = this.currentFolder.Save(SaveMode.NoConflictResolutionForceSave);
                    if (coreFolder == null)
                    {
                        this.currentFolder.PropertyBag.Load(null);
                    }
                    if (folderSaveResult.OperationResult != OperationResult.Succeeded)
                    {
                        ExTraceGlobals.SessionTracer.TraceWarning <StoreObjectId, LocalizedException>((long)this.currentFolder.Session.GetHashCode(), "Failed to save RecentBindingHistory on folder {0}. Error: {1}.", objectId, folderSaveResult.Exception);
                        ProcessInfoEventLogger.Log(StorageEventLogConstants.Tuple_ErrorSavingFolderBindHistory, objectId.ToString(), new object[]
                        {
                            objectId,
                            mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(),
                            mailboxSession.MailboxGuid,
                            mailboxSession.LogonType,
                            IdentityHelper.SidFromLogonIdentity(mailboxSession.Identity),
                            COWTriggerAction.FolderBind,
                            folderSaveResult.Exception
                        });
                    }
                }
                finally
                {
                    if (coreFolder != null)
                    {
                        coreFolder.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 17
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");
     if (settings.CurrentFolderId.Equals(dumpster.RecoverableItemsPurgesFolderId))
     {
         ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Attempt to hard delete items in the dumpster purges folder");
         throw new RecoverableItemsAccessDeniedException("Purges");
     }
     if (settings.CurrentFolderId.Equals(dumpster.RecoverableItemsDiscoveryHoldsFolderId))
     {
         ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Attempt to hard delete items in the dumpster discoveryholds folder");
         throw new RecoverableItemsAccessDeniedException("DiscoveryHolds");
     }
     if (COWTriggerAction.HardDelete == operation)
     {
         try
         {
             StoreObjectId storeObjectId;
             if (settings.IsOnlyInPlaceHoldEnabled())
             {
                 settings.Session.CowSession.CheckAndCreateDiscoveryHoldsFolder(callbackContext.SessionWithBestAccess);
                 storeObjectId = dumpster.RecoverableItemsDiscoveryHoldsFolderId;
             }
             else
             {
                 storeObjectId = dumpster.RecoverableItemsPurgesFolderId;
             }
             if (!settings.CurrentFolderId.Equals(storeObjectId))
             {
                 dumpster.MoveItemsToDumpster(callbackContext.SessionWithBestAccess, storeObjectId, itemIds);
             }
             return;
         }
         catch (DumpsterOperationException)
         {
             if (dumpster.Results.AnyPartialResultFailure())
             {
                 throw;
             }
             List <GroupOperationResult> partialResults = dumpster.Results.GetPartialResults();
             ExTraceGlobals.SessionTracer.TraceWarning <GroupOperationResult>((long)dumpster.StoreSession.GetHashCode(), "DumpsterOperationException during HardDelete and Partial success: leave the current results {0}", partialResults[partialResults.Count - 1]);
             return;
         }
     }
     dumpster.CopyItemsToDumpster(callbackContext.SessionWithBestAccess, dumpster.RecoverableItemsPurgesFolderId, itemIds, COWTriggerAction.DoneWithMessageDelete == operation);
 }
Ejemplo n.º 18
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)
        {
            if (!COWContactLogging.COWContactLoggingConfiguration.Instance.IsLoggingEnabled())
            {
                return(CowClientOperationSensitivity.Skip);
            }
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <FolderChangeOperationFlags>(flags, "flags");
            Util.ThrowOnNullArgument(sourceSession, "sourceSession");
            if (!onBeforeNotification)
            {
                COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipGroupOperation: not OnBeforeNotification");
                return(CowClientOperationSensitivity.Skip);
            }
            COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipGroupOperation: SourceFolderId.ObjectType={0}, DestinationFolderId.ObjectType={1}", new object[]
            {
                (sourceFolderId == null) ? "<<Null>>" : sourceFolderId.ObjectType,
                (destinationFolderId == null) ? "<<Null>>" : destinationFolderId.ObjectType
            });
            bool flag = true;

            if ((sourceFolderId != null && sourceFolderId.ObjectType == StoreObjectType.ContactsFolder) || (destinationFolderId != null && destinationFolderId.ObjectType == StoreObjectType.ContactsFolder))
            {
                flag = false;
            }
            else if (itemIds != null)
            {
                foreach (StoreObjectId storeObjectId in itemIds)
                {
                    COWContactLogging.Tracer.TraceDebug <StoreObjectType>((long)this.GetHashCode(), "COWContactLogging.SkipGroupOperation: ItemId.ObjectType = {0}", storeObjectId.ObjectType);
                    if (storeObjectId.ObjectType == StoreObjectType.Contact || storeObjectId.ObjectType == StoreObjectType.DistributionList)
                    {
                        flag = false;
                        break;
                    }
                }
            }
            if (!flag)
            {
                foreach (IContactChangeTracker contactChangeTracker in COWContactLogging.ChangeTrackers)
                {
                    if (contactChangeTracker.ShouldLogGroupOperation(operation, sourceSession, sourceFolderId, destinationSession, destinationFolderId, itemIds))
                    {
                        COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipGroupOperation: A tracker interested.");
                        COWContactLogging.ContactChangeLogEvent contactChangeLogEvent = new COWContactLogging.ContactChangeLogEvent();
                        contactChangeLogEvent.Add("Action", operation.ToString());
                        contactChangeLogEvent.Add("FolderChangeOperationFlags", flags.ToString());
                        contactChangeLogEvent.Add("ClientInfo", sourceSession.ClientInfoString);
                        if (destinationSession != null && destinationSession.ClientInfoString != sourceSession.ClientInfoString)
                        {
                            contactChangeLogEvent.Add("DestinationClientInfo", destinationSession.ClientInfoString);
                        }
                        if (sourceFolderId != null)
                        {
                            contactChangeLogEvent.Add("FolderId", sourceFolderId.ToString());
                        }
                        if (destinationFolderId != null && !object.Equals(sourceFolderId, destinationFolderId))
                        {
                            contactChangeLogEvent.Add("DestinationFolderId", destinationFolderId.ToString());
                        }
                        if (destinationSession != null && !object.Equals(sourceSession.MailboxGuid, destinationSession.MailboxGuid))
                        {
                            contactChangeLogEvent.Add("DestinationMailboxGuid", destinationSession.MailboxGuid.ToString());
                        }
                        string value = this.SanitizePropertyValueForLogging(itemIds);
                        contactChangeLogEvent.Add("ItemIds", value);
                        ContactChangeLogger contactChangeLogger = new ContactChangeLogger(sourceSession);
                        contactChangeLogger.LogEvent(contactChangeLogEvent);
                        break;
                    }
                }
            }
            return(CowClientOperationSensitivity.Skip);
        }
Ejemplo n.º 19
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");
            Util.ThrowOnNullArgument(settings, "settings");
            Util.ThrowOnNullArgument(sourceSession, "sourceSession");
            if (onDumpster)
            {
                return(CowClientOperationSensitivity.Skip);
            }
            if (!onBeforeNotification)
            {
                return(CowClientOperationSensitivity.Skip);
            }
            bool flag;

            if (!settings.HoldEnabled())
            {
                flag = true;
            }
            else
            {
                switch (operation)
                {
                case COWTriggerAction.Move:
                case COWTriggerAction.MoveToDeletedItems:
                {
                    Util.ThrowOnNullArgument(sourceSession, "sourceSession");
                    if (destinationSession == null)
                    {
                        flag = true;
                        ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Destination session is null, meaning item moving to same mailbox, so don't keep a copy.");
                        goto IL_187;
                    }
                    Guid mailboxGuid  = destinationSession.MailboxGuid;
                    Guid mailboxGuid2 = sourceSession.MailboxGuid;
                    if (destinationSession.MailboxGuid == sourceSession.MailboxGuid)
                    {
                        flag = true;
                        ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Mailbox guids are the same, meaning item moving to same mailbox, so don't keep a copy.");
                        goto IL_187;
                    }
                    if (destinationSession is MailboxSession && sourceSession is MailboxSession && string.Compare(((MailboxSession)sourceSession).MailboxOwner.LegacyDn, ((MailboxSession)destinationSession).MailboxOwner.LegacyDn, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        flag = true;
                        ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "MailboxOwner.LegacyDistinguishedName is the same, meaning same person owns both mailboxes (eg primary and archive), so don't keep a copy.");
                        goto IL_187;
                    }
                    flag = false;
                    ExTraceGlobals.SessionTracer.TraceDebug((long)dumpster.StoreSession.GetHashCode(), "Item moving to a different mailbox owned by someone else. Keep a copy.");
                    goto IL_187;
                }

                case COWTriggerAction.HardDelete:
                    flag = (settings.IsMrmAction() && DumpsterFolderHelper.IsDumpsterFolder(callbackContext.SessionWithBestAccess, sourceFolderId));
                    goto IL_187;

                case COWTriggerAction.DoneWithMessageDelete:
                    flag = false;
                    goto IL_187;
                }
                flag = true;
            }
IL_187:
            if (flag)
            {
                return(CowClientOperationSensitivity.Skip);
            }
            if (COWSession.IsDelegateSession(sourceSession))
            {
                return(CowClientOperationSensitivity.Capture);
            }
            return(CowClientOperationSensitivity.CaptureAndPerformOperation);
        }
Ejemplo n.º 20
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)
        {
            if (!COWContactLogging.COWContactLoggingConfiguration.Instance.IsLoggingEnabled())
            {
                return(true);
            }
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            if (item == null)
            {
                COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: Item is null");
                return(true);
            }
            if (!onBeforeNotification)
            {
                COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: Not onBeforeNotification");
                return(true);
            }
            string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);

            COWContactLogging.Tracer.TraceDebug <string>((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: ItemClass: {0}", valueOrDefault);
            if (ObjectClass.IsPlace(valueOrDefault))
            {
                return(true);
            }
            if (!ObjectClass.IsContact(valueOrDefault) && !ObjectClass.IsDistributionList(valueOrDefault) && !ObjectClass.IsContactsFolder(valueOrDefault))
            {
                return(true);
            }
            foreach (IContactChangeTracker contactChangeTracker in COWContactLogging.ChangeTrackers)
            {
                if (contactChangeTracker.ShouldLoadPropertiesForFurtherCheck(operation, valueOrDefault, itemId, item))
                {
                    COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.SkipItemOperation: A tracker interested.");
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 21
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)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            MailboxSession mailboxSession = session as MailboxSession;

            if (mailboxSession == null || !Utils.IsTeamMailbox(session) || !ClientInfo.MOMT.IsMatch(session.ClientInfoString))
            {
                return(true);
            }
            if (callbackContext.SiteMailboxMessageDedupState == COWProcessorState.DoNotProcess)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: skipping notification for item {0} because it should not be processed.", itemId);
                return(true);
            }
            if (callbackContext.SiteMailboxMessageDedupState == COWProcessorState.Processed)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: skipping notification for item {0} because it was already processed.", itemId);
                return(true);
            }
            if (callbackContext.SiteMailboxMessageDedupState == COWProcessorState.ProcessAfterSave)
            {
                return(onBeforeNotification);
            }
            if (onDumpster || item == null || operation != COWTriggerAction.Create)
            {
                callbackContext.SiteMailboxMessageDedupState = COWProcessorState.DoNotProcess;
                return(true);
            }
            if (!settings.IsSiteMailboxMessageDedupEnabled())
            {
                callbackContext.SiteMailboxMessageDedupState = COWProcessorState.DoNotProcess;
                COWSiteMailboxMessageDedup.Tracer.Information <string>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: skipping message dedup for site mailbox {0} because the feature is disabled for the mailbox.", mailboxSession.DisplayName);
                return(true);
            }
            ExDateTime now  = ExDateTime.Now;
            bool       flag = false;

            try
            {
                flag = this.IsDuplicateMessageBySiteMailboxDrop(mailboxSession, item);
            }
            catch (StoragePermanentException arg)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceError <StoragePermanentException>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: got store permanent exception: {0}", arg);
            }
            catch (StorageTransientException arg2)
            {
                COWSiteMailboxMessageDedup.Tracer.TraceError <StorageTransientException>((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: got store transient exception: {0}", arg2);
            }
            if (flag)
            {
                callbackContext.SiteMailboxMessageDedupState = COWProcessorState.ProcessAfterSave;
            }
            else
            {
                callbackContext.SiteMailboxMessageDedupState = COWProcessorState.DoNotProcess;
            }
            COWSiteMailboxMessageDedup.Tracer.TraceDebug((long)this.GetHashCode(), "COWSiteMailboxMessageDedup.SkipItemOperation: inspecting message {0} dragged & dropped to site mailbox {1} costed {2} milliseconds, and the result is {3}.", new object[]
            {
                itemId,
                mailboxSession.DisplayName,
                (ExDateTime.Now - now).TotalMilliseconds,
                callbackContext.SiteMailboxMessageDedupState
            });
            return(true);
        }
Ejemplo n.º 22
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            Util.ThrowOnNullArgument(item, "item");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.ItemOperation: Start.");
            string valueOrDefault = item.PropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty);

            COWContactLogging.Tracer.TraceDebug <string>((long)this.GetHashCode(), "COWContactLogging.ItemOperation: ItemClass: {0}", valueOrDefault);
            HashSet <StorePropertyDefinition> hashSet = new HashSet <StorePropertyDefinition>();
            List <IContactChangeTracker>      list    = new List <IContactChangeTracker>(COWContactLogging.ChangeTrackers.Length);

            foreach (IContactChangeTracker contactChangeTracker in COWContactLogging.ChangeTrackers)
            {
                if (contactChangeTracker.ShouldLoadPropertiesForFurtherCheck(operation, valueOrDefault, itemId, item))
                {
                    COWContactLogging.Tracer.TraceDebug <string>((long)this.GetHashCode(), "COWContactLogging.ItemOperation: Tracker {0} interested.", contactChangeTracker.Name);
                    list.Add(contactChangeTracker);
                    StorePropertyDefinition[] properties = contactChangeTracker.GetProperties(itemId, item);
                    if (properties != null && properties.Length > 0)
                    {
                        COWContactLogging.Tracer.TraceDebug <string, int>((long)this.GetHashCode(), "COWContactLogging.ItemOperation: Tracker {0} returned {1} properties for tracking", contactChangeTracker.Name, properties.Length);
                        hashSet.UnionWith(properties);
                    }
                }
            }
            if (hashSet.Count == 0)
            {
                COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.ItemOperation: No properties marked as interesting by any tracker.");
                return;
            }
            hashSet.Add(ItemSchema.Id);
            hashSet.Add(StoreObjectSchema.ItemClass);
            StorePropertyDefinition[] array = new StorePropertyDefinition[hashSet.Count];
            hashSet.CopyTo(array, 0, hashSet.Count);
            item.PropertyBag.Load(array);
            bool flag = false;

            foreach (IContactChangeTracker contactChangeTracker2 in list)
            {
                if (contactChangeTracker2.ShouldLogContact(itemId, item))
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                COWContactLogging.Tracer.TraceDebug((long)this.GetHashCode(), "COWContactLogging.ItemOperation: No trackers are interested after doing further checks.");
                return;
            }
            COWContactLogging.ContactChangeLogEvent contactChangeLogEvent = new COWContactLogging.ContactChangeLogEvent();
            contactChangeLogEvent.Add("ClientInfo", session.ClientInfoString);
            contactChangeLogEvent.Add("Action", operation.ToString());
            COWContactLogging.Tracer.TraceDebug <COWTriggerAction, string, int>((long)this.GetHashCode(), "COWContactLogging.ItemOperation: Tracking change {0} made by client {1} across a total of {2} properties", operation, session.ClientInfoString, hashSet.Count);
            this.LogInterestingPropertyValues(contactChangeLogEvent, operation, item, hashSet);
            ContactChangeLogger contactChangeLogger = new ContactChangeLogger(session);

            contactChangeLogger.LogEvent(contactChangeLogEvent);
        }
Ejemplo n.º 23
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);
 }
Ejemplo n.º 24
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)
        {
            Util.ThrowOnNullArgument(settings, "settings");
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            if (onDumpster)
            {
                return(true);
            }
            if (COWSettings.IsImapPoisonMessage(onBeforeNotification, operation, session, item))
            {
                return(true);
            }
            switch (operation)
            {
            case COWTriggerAction.Create:
            case COWTriggerAction.ItemBind:
            case COWTriggerAction.Submit:
                break;

            case COWTriggerAction.Update:
                return(!settings.LegalHoldEnabled());

            default:
                if (operation != COWTriggerAction.FolderBind)
                {
                    return(true);
                }
                break;
            }
            return(true);
        }
Ejemplo n.º 25
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);
        }
Ejemplo n.º 26
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            StoreObjectId storeObjectId = ((ICoreObject)item).StoreObjectId;

            if (storeObjectId is OccurrenceStoreObjectId)
            {
                return;
            }
            if (onBeforeNotification)
            {
                List <string> legallyDirtyProperties = item.GetLegallyDirtyProperties();
                if (legallyDirtyProperties != null && legallyDirtyProperties.Count > 0)
                {
                    COWSettings.AddMetadata(settings, item, operation);
                    if (state == COWTriggerActionState.Save)
                    {
                        StoreObjectId destinationFolderId;
                        if (settings.IsOnlyInPlaceHoldEnabled())
                        {
                            settings.Session.CowSession.CheckAndCreateDiscoveryHoldsFolder(callbackContext.SessionWithBestAccess);
                            destinationFolderId = dumpster.RecoverableItemsDiscoveryHoldsFolderId;
                        }
                        else
                        {
                            destinationFolderId = dumpster.RecoverableItemsVersionsFolderId;
                        }
                        StoreObjectId copyOnWriteGeneratedId = dumpster.CopyItemToDumpster(callbackContext.SessionWithBestAccess, destinationFolderId, item);
                        dumpster.Results.CopyOnWriteGeneratedId = copyOnWriteGeneratedId;
                        return;
                    }
                }
            }
            else if (operation == COWTriggerAction.Update && state == COWTriggerActionState.Save && result == OperationResult.Failed)
            {
                dumpster.RollbackItemVersion(callbackContext.SessionWithBestAccess, item, dumpster.Results.CopyOnWriteGeneratedId);
                dumpster.Results.CopyOnWriteGeneratedId = null;
            }
        }
Ejemplo n.º 27
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");
 }
Ejemplo n.º 28
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");
     Util.ThrowOnNullArgument(settings, "settings");
     Util.ThrowOnNullArgument(sourceSession, "sourceSession");
     if (onDumpster)
     {
         return(CowClientOperationSensitivity.Skip);
     }
     if (!onBeforeNotification)
     {
         return(CowClientOperationSensitivity.Skip);
     }
     if (operation != COWTriggerAction.SoftDelete)
     {
         return(CowClientOperationSensitivity.Skip);
     }
     if (COWSession.IsDelegateSession(sourceSession))
     {
         return(CowClientOperationSensitivity.Capture);
     }
     return(CowClientOperationSensitivity.CaptureAndPerformOperation);
 }
Ejemplo n.º 29
0
        public void ItemOperation(COWSettings settings, IDumpsterItemOperations dumpster, COWTriggerAction operation, COWTriggerActionState state, StoreSession session, StoreObjectId itemId, CoreItem item, CoreFolder folder, bool onBeforeNotification, OperationResult result, CallbackContext callbackContext)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <COWTriggerAction>(operation, "operation");
            EnumValidator.ThrowIfInvalid <COWTriggerActionState>(state, "state");
            EnumValidator.ThrowIfInvalid <OperationResult>(result, "result");
            Util.ThrowOnNullArgument(item, "item");
            Util.ThrowOnNullArgument(callbackContext, "callbackContext");
            if (callbackContext.COWGroupMessageWSPublishingState != COWProcessorState.ProcessAfterSave)
            {
                COWGroupMessageWSPublishing.Tracer.TraceError <COWProcessorState>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing because the state doesn't indicate processing is needed: {0}", callbackContext.COWGroupMessageWSPublishingState);
                return;
            }
            if (onBeforeNotification)
            {
                COWGroupMessageWSPublishing.Tracer.TraceError((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing because we should only publish after saving");
                return;
            }
            if (result != OperationResult.Succeeded)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug <OperationResult>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing of message because the operation wasn't successful: {0}", result);
                return;
            }
            MailboxSession mailboxSession = session as MailboxSession;

            if (mailboxSession == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceError <OperationResult>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing the session is not a mailbox session", result);
                return;
            }
            if (mailboxSession.MailboxOwner == null || mailboxSession.MailboxOwner.MailboxInfo == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceError <OperationResult>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: Skipping working set publishing, the session does not contain the mailbox info", result);
                return;
            }
            string    displayName = mailboxSession.DisplayName;
            string    groupId     = mailboxSession.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString();
            Exception ex          = this.groupWSPublisher.PublishGroupPost(item, displayName, groupId);

            if (ex == null)
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: working set publishing of message {0} from group mailbox successful", itemId);
            }
            else
            {
                COWGroupMessageWSPublishing.Tracer.TraceDebug <StoreObjectId, string>((long)this.GetHashCode(), "COWGroupMessageWSPublishing.ItemOperation: working set publishing of message {0} from group mailbox failed. Error: {1}", itemId, ex.ToString());
            }
            callbackContext.COWGroupMessageWSPublishingState = COWProcessorState.Processed;
        }
Ejemplo n.º 30
0
        internal static CoreItem CoreItemBind(StoreSession session, StoreId storeId, ItemBuilder.MapiMessageCreator mapiMessageCreator, ItemBindOption itemBindOption, ICollection <PropertyDefinition> propertiesToLoad, ref StoreObjectType storeObjectType)
        {
            Util.ThrowOnNullArgument(session, "session");
            EnumValidator.ThrowIfInvalid <ItemBindOption>(itemBindOption);
            Util.ThrowOnNullArgument(propertiesToLoad, "propertiesToLoad");
            bool     flag     = false;
            MapiProp mapiProp = null;
            PersistablePropertyBag persistablePropertyBag = null;
            AcrPropertyBag         acrPropertyBag         = null;
            CoreItem coreItem = null;
            CoreItem result2;

            using (CallbackContext callbackContext = new CallbackContext(session))
            {
                try
                {
                    session.OnBeforeItemChange(ItemChangeOperation.ItemBind, session, storeId, coreItem, callbackContext);
                    StoreObjectId storeObjectId;
                    byte[]        array;
                    StoreId.SplitStoreObjectIdAndChangeKey(storeId, out storeObjectId, out array);
                    session.CheckSystemFolderAccess(storeObjectId);
                    if (storeObjectId != null && !IdConverter.IsMessageId(storeObjectId))
                    {
                        throw new ArgumentException(ServerStrings.ExInvalidItemId);
                    }
                    bool flag2 = false;
                    OccurrenceStoreObjectId occurrenceStoreObjectId = storeObjectId as OccurrenceStoreObjectId;
                    IPropertyBagFactory     propertyBagFactory;
                    if (occurrenceStoreObjectId != null)
                    {
                        persistablePropertyBag = Item.CreateOccurrencePropertyBag(session, occurrenceStoreObjectId, propertiesToLoad);
                        storeObjectType        = StoreObjectType.CalendarItemOccurrence;
                        flag2 = true;
                        propertyBagFactory = new OccurrenceBagFactory(session, occurrenceStoreObjectId);
                    }
                    else
                    {
                        if (mapiMessageCreator != null)
                        {
                            mapiProp = mapiMessageCreator();
                        }
                        else if ((itemBindOption & ItemBindOption.SoftDeletedItem) == ItemBindOption.SoftDeletedItem)
                        {
                            mapiProp = session.GetMapiProp(storeObjectId, OpenEntryFlags.BestAccess | OpenEntryFlags.DeferredErrors | OpenEntryFlags.ShowSoftDeletes);
                        }
                        else
                        {
                            mapiProp = session.GetMapiProp(storeObjectId);
                        }
                        persistablePropertyBag = new StoreObjectPropertyBag(session, mapiProp, propertiesToLoad);
                        StoreObjectType storeObjectType2 = ItemBuilder.ReadStoreObjectTypeFromPropertyBag(persistablePropertyBag);
                        if (storeObjectType2 == storeObjectType)
                        {
                            flag2 = true;
                        }
                        else
                        {
                            storeObjectType = storeObjectType2;
                        }
                        propertyBagFactory = new RetryBagFactory(session);
                        if (storeObjectId != null && storeObjectId.ObjectType != storeObjectType)
                        {
                            storeObjectId = StoreObjectId.FromProviderSpecificId(storeObjectId.ProviderLevelItemId, storeObjectType);
                        }
                    }
                    ItemBuilder.CheckPrivateItem(session, persistablePropertyBag);
                    ItemCreateInfo itemCreateInfo = ItemCreateInfo.GetItemCreateInfo(storeObjectType);
                    if (flag2)
                    {
                        propertiesToLoad = null;
                    }
                    else
                    {
                        propertiesToLoad = ItemBuilder.GetPropertiesToLoad(itemBindOption, itemCreateInfo.Schema, propertiesToLoad);
                    }
                    acrPropertyBag = new AcrPropertyBag(persistablePropertyBag, itemCreateInfo.AcrProfile, storeObjectId, propertyBagFactory, array);
                    coreItem       = new CoreItem(session, acrPropertyBag, storeObjectId, array, Origin.Existing, ItemLevel.TopLevel, propertiesToLoad, itemBindOption);
                    flag           = true;
                    ConflictResolutionResult result = flag ? ConflictResolutionResult.Success : ConflictResolutionResult.Failure;
                    session.OnAfterItemChange(ItemChangeOperation.ItemBind, session, storeId, coreItem, result, callbackContext);
                    result2 = coreItem;
                }
                finally
                {
                    if (!flag)
                    {
                        Util.DisposeIfPresent(coreItem);
                        Util.DisposeIfPresent(acrPropertyBag);
                        Util.DisposeIfPresent(persistablePropertyBag);
                        Util.DisposeIfPresent(mapiProp);
                    }
                }
            }
            return(result2);
        }