Esempio n. 1
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            ADUser aduser = (ADUser)base.PrepareDataObject();

            MailboxTaskHelper.BlockRemoveOrDisableIfLitigationHoldEnabled(aduser, new Task.ErrorLoggerDelegate(base.WriteError), true, this.IgnoreLegalHold.ToBool());
            MailboxTaskHelper.BlockRemoveOrDisableIfDiscoveryHoldEnabled(aduser, new Task.ErrorLoggerDelegate(base.WriteError), true, this.IgnoreLegalHold.ToBool());
            if (ComplianceConfigImpl.JournalArchivingHardeningEnabled)
            {
                MailboxTaskHelper.BlockRemoveOrDisableMailUserIfJournalArchiveEnabled(base.DataSession as IRecipientSession, this.ConfigurationSession, aduser, new Task.ErrorLoggerDelegate(base.WriteError), true, false);
            }
            if (!aduser.ExchangeVersion.IsOlderThan(ADUserSchema.ArchiveGuid.VersionAdded))
            {
                if (aduser.ArchiveGuid != Guid.Empty)
                {
                    if (!this.PreventRecordingPreviousDatabase)
                    {
                        aduser.DisabledArchiveGuid     = aduser.ArchiveGuid;
                        aduser.DisabledArchiveDatabase = aduser.ArchiveDatabase;
                    }
                    else
                    {
                        aduser.DisabledArchiveGuid     = Guid.Empty;
                        aduser.DisabledArchiveDatabase = null;
                    }
                }
                aduser.ArchiveGuid             = Guid.Empty;
                aduser.ArchiveName             = null;
                aduser.ArchiveDatabase         = null;
                aduser.ArchiveStatus           = (aduser.ArchiveStatus &= ~ArchiveStatusFlags.Active);
                aduser.AllowArchiveAddressSync = false;
            }
            if ("Archive" == base.ParameterSetName)
            {
                MailboxTaskHelper.ClearExchangeProperties(aduser, DisableMailUserBase <MailUserIdParameter> .MailboxMovePropertiesToReset);
                TaskLogger.Trace("DisableMailbox -Archive skipping PrepareDataObject", new object[0]);
                TaskLogger.LogExit();
                return(aduser);
            }
            int        recipientSoftDeletedStatus = aduser.RecipientSoftDeletedStatus;
            DateTime?  whenSoftDeleted            = aduser.WhenSoftDeleted;
            Guid       disabledArchiveGuid        = aduser.DisabledArchiveGuid;
            ADObjectId disabledArchiveDatabase    = aduser.DisabledArchiveDatabase;

            MailboxTaskHelper.ClearExchangeProperties(aduser, RecipientConstants.DisableMailUserBase_PropertiesToReset);
            aduser.SetExchangeVersion(null);
            aduser.OverrideCorruptedValuesWithDefault();
            aduser.propertyBag.SetField(ADRecipientSchema.RecipientSoftDeletedStatus, recipientSoftDeletedStatus);
            aduser.propertyBag.SetField(ADRecipientSchema.WhenSoftDeleted, whenSoftDeleted);
            if (disabledArchiveGuid != Guid.Empty)
            {
                aduser.propertyBag.SetField(ADUserSchema.DisabledArchiveGuid, disabledArchiveGuid);
                aduser.propertyBag.SetField(ADUserSchema.DisabledArchiveDatabase, disabledArchiveDatabase);
            }
            TaskLogger.LogExit();
            return(aduser);
        }
Esempio n. 2
0
 protected override void InternalValidate()
 {
     this.latencyContext = ProvisioningPerformanceHelper.StartLatencyDetection(this);
     base.InternalValidate();
     MailboxTaskHelper.BlockRemoveOrDisableIfLitigationHoldEnabled(base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false, this.IgnoreLegalHold.ToBool());
     MailboxTaskHelper.BlockRemoveOrDisableIfDiscoveryHoldEnabled(base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false, this.IgnoreLegalHold.ToBool());
     if (ComplianceConfigImpl.JournalArchivingHardeningEnabled)
     {
         MailboxTaskHelper.BlockRemoveOrDisableMailUserIfJournalArchiveEnabled(base.DataSession as IRecipientSession, this.ConfigurationSession, base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false, this.isSyncOperation);
     }
 }
Esempio n. 3
0
        protected override IConfigurable ResolveDataObject()
        {
            ADRecipient adrecipient = (ADRecipient)base.ResolveDataObject();

            MailboxTaskHelper.BlockRemoveOrDisableIfLitigationHoldEnabled((ADUser)adrecipient, new Task.ErrorLoggerDelegate(base.WriteError), true, this.IgnoreLegalHold.ToBool());
            MailboxTaskHelper.BlockRemoveOrDisableIfDiscoveryHoldEnabled((ADUser)adrecipient, new Task.ErrorLoggerDelegate(base.WriteError), true, this.IgnoreLegalHold.ToBool());
            MailboxTaskHelper.BlockRemoveOrDisableIfJournalNDRMailbox((ADUser)adrecipient, this.TenantLocalConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), true);
            MailboxTaskHelper.ValidateNoOABsAssignedToArbitrationMailbox((ADUser)adrecipient, this.DisableArbitrationMailboxWithOABsAllowed.ToBool(), new Task.ErrorLoggerDelegate(base.WriteError), Strings.ErrorDisableArbitrationMailboxWithOABsAssigned(this.Identity.ToString()));
            if (MailboxTaskHelper.ExcludeArbitrationMailbox(adrecipient, this.Arbitration) || MailboxTaskHelper.ExcludePublicFolderMailbox(adrecipient, this.PublicFolder) || MailboxTaskHelper.ExcludeMailboxPlan(adrecipient, false))
            {
                base.WriteError(new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(this.Identity.ToString(), typeof(ADUser).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), ErrorCategory.InvalidData, this.Identity);
            }
            if (ComplianceConfigImpl.JournalArchivingHardeningEnabled)
            {
                MailboxTaskHelper.BlockRemoveOrDisableMailboxIfJournalArchiveEnabled(base.DataSession as IRecipientSession, this.ConfigurationSession, (ADUser)adrecipient, new Task.ErrorLoggerDelegate(base.WriteError), true);
            }
            return(adrecipient);
        }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     this.isToInactiveMailbox         = false;
     this.isDisconnectInactiveMailbox = false;
     if (this.Identity != null)
     {
         base.InternalValidate();
         this.isToInactiveMailbox         = this.IsToInactiveMailbox();
         this.isDisconnectInactiveMailbox = this.IsDisconnectInactiveMailbox();
         if (!this.isToInactiveMailbox && !this.isDisconnectInactiveMailbox)
         {
             MailboxTaskHelper.BlockRemoveOrDisableIfLitigationHoldEnabled(base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false, this.IgnoreLegalHold.ToBool());
             MailboxTaskHelper.BlockRemoveOrDisableIfDiscoveryHoldEnabled(base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false, this.IgnoreLegalHold.ToBool());
         }
         MailboxTaskHelper.BlockRemoveOrDisableIfJournalNDRMailbox(base.DataObject, this.TenantLocalConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), false);
         if (ComplianceConfigImpl.JournalArchivingHardeningEnabled && !this.skipJournalArchivingCheck)
         {
             MailboxTaskHelper.BlockRemoveOrDisableMailboxIfJournalArchiveEnabled(base.DataSession as IRecipientSession, this.ConfigurationSession, base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), false);
         }
         if (base.DataObject.RecipientTypeDetails == RecipientTypeDetails.ArbitrationMailbox && this.ArbitrationMailboxUsageValidationRequired)
         {
             ADUser dataObject = base.DataObject;
             Task.ErrorLoggerDelegate writeError = new Task.ErrorLoggerDelegate(base.WriteError);
             TIdentity identity = this.Identity;
             MailboxTaskHelper.ValidateNotBuiltInArbitrationMailbox(dataObject, writeError, Strings.ErrorRemoveArbitrationMailbox(identity.ToString()));
             ADUser                   dataObject2 = base.DataObject;
             IRecipientSession        tenantGlobalCatalogSession = base.TenantGlobalCatalogSession;
             Task.ErrorLoggerDelegate writeError2 = new Task.ErrorLoggerDelegate(base.WriteError);
             TIdentity                identity2   = this.Identity;
             MailboxTaskHelper.ValidateArbitrationMailboxHasNoGroups(dataObject2, tenantGlobalCatalogSession, writeError2, Strings.ErrorRemoveMailboxWithAssociatedApprovalRecipents(identity2.ToString()));
             ADUser dataObject3   = base.DataObject;
             bool   overrideCheck = this.RemoveArbitrationMailboxWithOABsAllowed.ToBool();
             Task.ErrorLoggerDelegate writeError3 = new Task.ErrorLoggerDelegate(base.WriteError);
             TIdentity identity3 = this.Identity;
             MailboxTaskHelper.ValidateNoOABsAssignedToArbitrationMailbox(dataObject3, overrideCheck, writeError3, Strings.ErrorRemoveArbitrationMailboxWithOABsAssigned(identity3.ToString()));
             ADUser            dataObject4 = base.DataObject;
             IRecipientSession tenantGlobalCatalogSession2 = base.TenantGlobalCatalogSession;
             ADObjectId        rootOrgContainerId          = base.RootOrgContainerId;
             bool isPresent = this.RemoveLastArbitrationMailboxAllowed.IsPresent;
             Task.ErrorLoggerDelegate writeError4 = new Task.ErrorLoggerDelegate(base.WriteError);
             TIdentity identity4 = this.Identity;
             MailboxTaskHelper.ValidateNotLastArbitrationMailbox(dataObject4, tenantGlobalCatalogSession2, rootOrgContainerId, isPresent, writeError4, Strings.ErrorCannotRemoveLastArbitrationMailboxInOrganization(identity4.ToString()));
         }
         if (this.AuditLog)
         {
             if (base.DataObject.RecipientTypeDetails != RecipientTypeDetails.AuditLogMailbox)
             {
                 LocalizedException    exception = new RecipientTaskException(Strings.ErrorSpecifiedMailboxShouldBeAuditLogMailbox(base.DataObject.Identity.ToString()));
                 ExchangeErrorCategory category  = ExchangeErrorCategory.Context;
                 TIdentity             identity5 = this.Identity;
                 base.WriteError(exception, category, identity5.ToString());
             }
         }
         else if (base.DataObject.RecipientTypeDetails == RecipientTypeDetails.AuditLogMailbox)
         {
             LocalizedException    exception2 = new RecipientTaskException(Strings.ErrorAuditLogMailboxShouldBeDeletedWithAuditLogSpecified(base.DataObject.Identity.ToString()));
             ExchangeErrorCategory category2  = ExchangeErrorCategory.Context;
             TIdentity             identity6  = this.Identity;
             base.WriteError(exception2, category2, identity6.ToString());
         }
     }
     else
     {
         this.InternalValidateStoreMailboxIdentity();
         try
         {
             this.mailboxStatistics = (MailboxStatistics)base.GetDataObject <MailboxStatistics>(this.StoreMailboxIdentity, this.mapiSession, MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(this.database), new LocalizedString?(Strings.ErrorStoreMailboxNotFound(this.StoreMailboxIdentity.ToString(), this.Database.ToString())), new LocalizedString?(Strings.ErrorStoreMailboxNotUnique(this.StoreMailboxIdentity.ToString(), this.Database.ToString())), ExchangeErrorCategory.Client);
             MailboxTaskHelper.ValidateMailboxIsDisconnected(base.TenantGlobalCatalogSession, this.mailboxStatistics.MailboxGuid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
             this.mailboxStatistics.Database = this.database.Identity;
         }
         catch (DataSourceTransientException exception3)
         {
             base.WriteError(exception3, ExchangeErrorCategory.ServerTransient, this.StoreMailboxIdentity);
         }
     }
     if (this.PublicFolder)
     {
         Organization orgContainer = this.TenantLocalConfigurationSession.GetOrgContainer();
         if (orgContainer.DefaultPublicFolderMailbox.HierarchyMailboxGuid == Guid.Empty && !this.Force)
         {
             LocalizedException    exception4 = new RecipientTaskException(Strings.ErrorPrimaryPublicFolderMailboxNotFound);
             ExchangeErrorCategory category3  = ExchangeErrorCategory.Context;
             TIdentity             identity7  = this.Identity;
             base.WriteError(exception4, category3, identity7.ToString());
         }
         if (this.currentOrganizationId == null || this.currentOrganizationId != base.DataObject.OrganizationId)
         {
             this.currentOrganizationId = base.DataObject.OrganizationId;
             TenantPublicFolderConfigurationCache.Instance.RemoveValue(base.DataObject.OrganizationId);
         }
         MailboxTaskHelper.RemoveOrDisablePublicFolderMailbox(base.DataObject, Guid.Empty, this.tenantLocalConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), false, this.Force);
     }
     TaskLogger.LogExit();
 }