コード例 #1
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            ADObjectId adobjectId = null;
            Guid       guid       = Guid.Empty;
            string     text       = string.Empty;
            bool       flag       = this.ShouldSoftDeleteObject();
            ADUser     dataObject = base.DataObject;

            if (Globals.IsMicrosoftHostedOnly)
            {
                if (flag)
                {
                    bool flag2 = SoftDeletedTaskHelper.MSOSyncEnabled(this.ConfigurationSession, dataObject.OrganizationId);
                    bool includeInGarbageCollection = (!flag2 || base.ForReconciliation) && !this.isToInactiveMailbox;
                    SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, dataObject, includeInGarbageCollection, this.isToInactiveMailbox);
                }
                else
                {
                    if (this.isDisconnectInactiveMailbox)
                    {
                        SoftDeletedTaskHelper.UpdateMailboxForDisconnectInactiveMailbox(dataObject);
                        base.DataSession.Save(dataObject);
                        TaskLogger.LogExit();
                        this.LogRemoveMailboxDetails(dataObject);
                        return;
                    }
                    dataObject.RecipientSoftDeletedStatus = 0;
                }
            }
            if (this.Identity != null)
            {
                adobjectId = base.DataObject.Database;
                guid       = base.DataObject.ExchangeGuid;
                if (adobjectId == null)
                {
                    TaskLogger.Trace("The homeMDB is empty for this user, we just try to remove the user AD object", new object[0]);
                }
                else if (guid == Guid.Empty)
                {
                    TaskLogger.Trace("The ExchangeGuid is empty for this user, we just try to remove the user AD object", new object[0]);
                }
                else if (base.DataObject.RecipientTypeDetails == RecipientTypeDetails.MailboxPlan)
                {
                    TaskLogger.Trace("This user is MailboxPlan, we just try to remove the user AD object", new object[0]);
                }
                else if (!flag)
                {
                    try
                    {
                        DatabaseLocationInfo databaseLocationInfo = null;
                        try
                        {
                            databaseLocationInfo = ActiveManager.GetActiveManagerInstance().GetServerForDatabase(adobjectId.ObjectGuid);
                        }
                        catch (ObjectNotFoundException exception)
                        {
                            base.WriteError(exception, ExchangeErrorCategory.ServerOperation, null);
                        }
                        if (databaseLocationInfo == null)
                        {
                            if (this.Permanent)
                            {
                                base.WriteError(new TaskInvalidOperationException(Strings.ErrorGetServerNameFromMailbox(base.DataObject.Identity.ToString())), ExchangeErrorCategory.ServerOperation, base.DataObject);
                            }
                            else
                            {
                                TaskLogger.Trace("cannot get the server name for mailbox {0}", new object[]
                                {
                                    base.DataObject.Identity
                                });
                            }
                        }
                        else
                        {
                            text = databaseLocationInfo.ServerFqdn;
                            base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(text));
                            this.mapiSession = new MapiAdministrationSession(databaseLocationInfo.ServerLegacyDN, Fqdn.Parse(text));
                        }
                    }
                    catch (MapiPermanentException ex)
                    {
                        if (this.Permanent)
                        {
                            base.WriteError(ex, ExchangeErrorCategory.ServerOperation, this.Identity);
                        }
                        else
                        {
                            TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                            {
                                ex
                            });
                        }
                    }
                    catch (MapiRetryableException ex2)
                    {
                        if (this.Permanent)
                        {
                            base.WriteError(ex2, ExchangeErrorCategory.ServerTransient, this.Identity);
                        }
                        else
                        {
                            TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                            {
                                ex2
                            });
                        }
                    }
                    try
                    {
                        if (dataObject != null && base.ForReconciliation)
                        {
                            base.DataObject.ExternalDirectoryObjectId = string.Empty;
                        }
                        base.DataObject.PreviousDatabase = base.DataObject.Database;
                        base.DataSession.Save(base.DataObject);
                    }
                    catch (DataSourceTransientException exception2)
                    {
                        base.WriteError(exception2, ExchangeErrorCategory.ServerTransient, null);
                    }
                    catch (InvalidObjectOperationException)
                    {
                    }
                    catch (DataValidationException)
                    {
                    }
                    catch (ADOperationException)
                    {
                    }
                }
                base.InternalProcessRecord();
                this.LogRemoveMailboxDetails(dataObject);
            }
            if (this.StoreMailboxIdentity != null || this.Permanent)
            {
                if (this.Permanent)
                {
                    if (!(guid != Guid.Empty) || adobjectId == null)
                    {
                        goto IL_5A0;
                    }
                    try
                    {
                        base.WriteVerbose(Strings.VerboseDeleteMailboxInStore(guid.ToString(), adobjectId.ToString()));
                        this.mapiSession.DeleteMailbox(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), guid));
                        goto IL_5A0;
                    }
                    catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex3)
                    {
                        TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                        {
                            ex3
                        });
                        base.WriteVerbose(ex3.LocalizedString);
                        goto IL_5A0;
                    }
                    catch (DataSourceOperationException exception3)
                    {
                        base.WriteError(exception3, ExchangeErrorCategory.ServerOperation, base.DataObject);
                        goto IL_5A0;
                    }
                }
                try
                {
                    base.WriteVerbose(Strings.VerboseDeleteMailboxInStore(this.mailboxStatistics.MailboxGuid.ToString(), this.mailboxStatistics.Database.ToString()));
                    ((IConfigDataProvider)this.mapiSession).Delete(this.mailboxStatistics);
                    goto IL_5A0;
                }
                catch (DataSourceOperationException exception4)
                {
                    base.WriteError(exception4, ExchangeErrorCategory.ServerOperation, (this.Identity == null) ? this.StoreMailboxIdentity : this.Identity);
                    goto IL_5A0;
                }
            }
            if (this.mapiSession != null)
            {
                try
                {
                    TIdentity identity = this.Identity;
                    base.WriteVerbose(Strings.VerboseSyncMailboxWithDS(identity.ToString(), base.DataObject.Database.ToString(), text));
                    bool flag3 = true;
                    if (base.DataObject.Database == null || Guid.Empty == base.DataObject.Database.ObjectGuid)
                    {
                        flag3 = false;
                        TaskLogger.Trace("Cannot get the database for mailbox '{0}'", new object[]
                        {
                            base.DataObject.Identity
                        });
                    }
                    if (Guid.Empty == base.DataObject.ExchangeGuid)
                    {
                        flag3 = false;
                        TaskLogger.Trace("Cannot get the mailbox guid for mailbox '{0}'", new object[]
                        {
                            base.DataObject.Identity
                        });
                    }
                    if (flag3)
                    {
                        this.mapiSession.SyncMailboxWithDS(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(base.DataObject.Database), base.DataObject.ExchangeGuid));
                    }
                }
                catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex4)
                {
                    TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                    {
                        ex4
                    });
                    base.WriteVerbose(ex4.LocalizedString);
                }
                catch (DataSourceTransientException ex5)
                {
                    TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                    {
                        ex5
                    });
                    this.WriteWarning(ex5.LocalizedString);
                }
                catch (DataSourceOperationException ex6)
                {
                    TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                    {
                        ex6
                    });
                    this.WriteWarning(ex6.LocalizedString);
                }
            }
IL_5A0:
            if (!flag && this.mailboxStatistics != null)
            {
                this.mailboxStatistics.Dispose();
                this.mailboxStatistics = null;
            }
            this.DisposeMapiSession();
            TaskLogger.LogExit();
        }
コード例 #2
0
        private bool IsToInactiveMailbox()
        {
            ADUser dataObject = base.DataObject;

            return(this.ShouldSoftDeleteObject() && SoftDeletedTaskHelper.MSOSyncEnabled(this.ConfigurationSession, dataObject.OrganizationId) && dataObject.IsInLitigationHoldOrInplaceHold && !this.IgnoreLegalHold);
        }
コード例 #3
0
        protected override bool ShouldSoftDeleteObject()
        {
            ADRecipient dataObject = base.DataObject;

            return(dataObject != null && !(dataObject.OrganizationId == null) && dataObject.OrganizationId.ConfigurationUnit != null && !this.Permanent && Globals.IsMicrosoftHostedOnly && SoftDeletedTaskHelper.MSOSyncEnabled(this.ConfigurationSession, dataObject.OrganizationId));
        }