private void RemoveMailUser()
 {
     if (this.mailUser == null)
     {
         this.WriteWarning(Strings.WarningJournalArchiveMailboxHasNoMailUser);
         return;
     }
     if (DisableJournalArchiving.ShouldSoftDeleteUser(this.mailUser))
     {
         SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, this.mailUser, false);
         SoftDeletedTaskHelper.UpdateExchangeGuidForMailEnabledUser(this.mailUser);
         this.mailUser.JournalArchiveAddress = SmtpAddress.NullReversePath;
         base.WriteVerbose(TaskVerboseStringHelper.GetDeleteObjectVerboseString(this.mailUser.Identity, base.DataSession, typeof(ADUser)));
         try
         {
             try
             {
                 RecipientTaskHelper.CreateSoftDeletedObjectsContainerIfNecessary(this.mailUser.Id.Parent, base.DomainController);
                 base.DataSession.Save(this.mailUser);
             }
             catch (DataSourceTransientException exception)
             {
                 base.WriteError(exception, ExchangeErrorCategory.ServerTransient, null);
             }
             return;
         }
         finally
         {
             base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
         }
     }
     base.WriteError(new RecipientTaskException(Strings.ErrorDisableJournalArchiveMailuserNotSoftDeleted), ExchangeErrorCategory.Client, this.mailUser.Identity);
 }
示例#2
0
 protected override void InternalProcessRecord()
 {
     if (Globals.IsMicrosoftHostedOnly)
     {
         ADUser dataObject = base.DataObject;
         if (this.ShouldSoftDeleteObject())
         {
             SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, dataObject, this.ForReconciliation);
         }
         else
         {
             dataObject.propertyBag.SetField(ADRecipientSchema.RecipientSoftDeletedStatus, 0);
         }
     }
     base.InternalProcessRecord();
 }
示例#3
0
 protected override void InternalProcessRecord()
 {
     if (Globals.IsMicrosoftHostedOnly)
     {
         ADUser dataObject = base.DataObject;
         if (this.ShouldSoftDeleteObject())
         {
             SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, dataObject, this.ForReconciliation);
             SoftDeletedTaskHelper.UpdateExchangeGuidForMailEnabledUser(dataObject);
         }
         else
         {
             dataObject.RecipientSoftDeletedStatus = 0;
         }
     }
     base.InternalProcessRecord();
 }
        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();
        }
示例#5
0
 internal static void UpdateRecipientForSoftDelete(IRecipientSession session, ADUser recipient, bool includeInGarbageCollection)
 {
     SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(session, recipient, includeInGarbageCollection, false);
 }