protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            if (base.HasErrors)
            {
                TaskLogger.LogExit();
                return;
            }
            if (!this.ClearHostServer && this.m_dbCopy.HostServer != null)
            {
                base.VerifyIsWithinScopes((IConfigurationSession)base.DataSession, DatabaseTasksHelper.GetServerObject(new ServerIdParameter(this.m_dbCopy.HostServer), (IConfigurationSession)base.DataSession, this.RootId, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <Server>)), true, new DataAccessTask <DatabaseCopy> .ADObjectOutOfScopeString(Strings.ErrorServerOutOfScope));
            }
            Database database = this.m_dbCopy.GetDatabase <Database>();

            if (database != null)
            {
                MapiTaskHelper.VerifyDatabaseIsWithinScope(base.SessionSettings, database, new Task.ErrorLoggerDelegate(base.WriteError));
                if (database.Servers != null && database.Servers.Length > 0)
                {
                    MapiTaskHelper.VerifyServerIsWithinScope(database, new Task.ErrorLoggerDelegate(base.WriteError), (ITopologyConfigurationSession)this.ConfigurationSession);
                }
            }
            if (this.DataObject.IsModified(DatabaseCopySchema.ReplayLag) && this.m_dbCopy.ReplayLagTime != TimeSpan.FromSeconds(0.0))
            {
                this.WriteWarning(Strings.WarningReplayLagTimeMustBeLessThanSafetyNetHoldTime);
            }
        }
 protected override void InternalValidate()
 {
     this.m_output = new HaTaskOutputHelper("Move-MailboxDatabaseMaster", new Task.TaskErrorLoggingDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskProgressLoggingDelegate(base.WriteProgress), this.GetHashCode());
     try
     {
         this.CheckParameterCombination();
         if (this.CommandType != MoveActiveMailboxDatabase.CommandTypes.MoveSingleDatabase)
         {
             this.InternalValidateServerMode();
         }
         else
         {
             this.InternalValidateDatabaseMode();
         }
         if (this.DataObject != null)
         {
             MapiTaskHelper.VerifyDatabaseIsWithinScope(base.SessionSettings, this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError));
         }
         if (this.TargetServerSpecified && this.m_targetServer.DatabaseCopyActivationDisabledAndMoveNow)
         {
             this.m_output.WriteWarning(Strings.ConfirmationMessageMoveMailboxDatabaseMasterToDisabledServer(this.m_targetServer.Fqdn));
         }
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
예제 #3
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     if (this.Identity != null)
     {
         this.Identity.AllowInvalid = true;
     }
     base.InternalValidate();
     if (base.HasErrors)
     {
         TaskLogger.LogExit();
         return;
     }
     this.ValidateDatabaseCopy();
     if (RemoteReplayConfiguration.IsServerRcrSource(ADObjectWrapperFactory.CreateWrapper(this.m_database), this.m_serverName, (ITopologyConfigurationSession)this.ConfigurationSession, out this.m_dbLocationInfo))
     {
         base.WriteError(new InvalidOperationException(Strings.ErrorDbMountedOnServer(this.m_database.Identity.ToString(), this.m_serverName)), ErrorCategory.InvalidOperation, this.m_database.Identity);
     }
     if (this.m_server != null)
     {
         base.VerifyIsWithinScopes((IConfigurationSession)base.DataSession, this.m_server, true, new DataAccessTask <DatabaseCopy> .ADObjectOutOfScopeString(Strings.ErrorServerOutOfScope));
     }
     if (this.m_database != null)
     {
         MapiTaskHelper.VerifyDatabaseIsWithinScope(base.SessionSettings, this.m_database, new Task.ErrorLoggerDelegate(base.WriteError));
         if (this.m_database.Servers != null && this.m_database.Servers.Length > 0)
         {
             MapiTaskHelper.VerifyServerIsWithinScope(this.m_database, new Task.ErrorLoggerDelegate(base.WriteError), (ITopologyConfigurationSession)this.ConfigurationSession);
         }
     }
     TaskLogger.LogExit();
 }
예제 #4
0
        protected override void InternalValidate()
        {
            if (this.Identity != null)
            {
                this.Identity.AllowInvalid = true;
            }
            base.InternalValidate();
            MapiTaskHelper.VerifyDatabaseIsWithinScope(base.SessionSettings, base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError));
            TDataObject dataObject = base.DataObject;

            if (dataObject.Servers != null)
            {
                TDataObject dataObject2 = base.DataObject;
                if (dataObject2.Servers.Length > 0)
                {
                    MapiTaskHelper.VerifyServerIsWithinScope(base.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), (ITopologyConfigurationSession)this.ConfigurationSession);
                }
            }
            TDataObject dataObject3 = base.DataObject;

            if (dataObject3.IsExchange2009OrLater)
            {
                TDataObject dataObject4 = base.DataObject;
                this.copies = dataObject4.AllDatabaseCopies;
                if (this.copies != null && this.copies.Length > 1)
                {
                    TDataObject   dataObject5 = base.DataObject;
                    Exception     exception   = new InvalidOperationException(Strings.ErrorMultipleDatabaseCopies(dataObject5.Identity.ToString()));
                    ErrorCategory category    = ErrorCategory.InvalidOperation;
                    TDataObject   dataObject6 = base.DataObject;
                    base.WriteError(exception, category, dataObject6.Identity);
                }
            }
        }
예제 #5
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            MapiTaskHelper.VerifyDatabaseIsWithinScope(base.SessionSettings, this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError));
            TDataObject dataObject = this.DataObject;

            if (dataObject.Servers != null)
            {
                TDataObject dataObject2 = this.DataObject;
                if (dataObject2.Servers.Length > 0)
                {
                    MapiTaskHelper.VerifyServerIsWithinScope(this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError), (ITopologyConfigurationSession)this.ConfigurationSession);
                }
            }
            ADPropertyDefinition[] deprecatedProperties = this.GetDeprecatedProperties();
            for (int i = 0; i < deprecatedProperties.Length; i++)
            {
                TDataObject dataObject3 = this.DataObject;
                if (dataObject3.IsModified(deprecatedProperties[i]))
                {
                    this.WriteWarning(Strings.WarnAboutDeprecatedParameter(deprecatedProperties[i].Name));
                }
            }
            TDataObject dataObject4 = this.DataObject;

            if (dataObject4.IsChanged(DatabaseSchema.DataMoveReplicationConstraintDefinition))
            {
                TDataObject dataObject5 = this.DataObject;
                DataMoveReplicationConstraintParameter dataMoveReplicationConstraint = dataObject5.DataMoveReplicationConstraint;
                ITopologyConfigurationSession          taskSession = (ITopologyConfigurationSession)base.DataSession;
                Database    database    = this.DataObject;
                TDataObject dataObject6 = this.DataObject;
                DatabaseTasksHelper.DataMoveReplicationConstraintFallBack(taskSession, database, dataObject6.DataMoveReplicationConstraint, out dataMoveReplicationConstraint);
                DataMoveReplicationConstraintParameter dataMoveReplicationConstraintParameter = dataMoveReplicationConstraint;
                TDataObject dataObject7 = this.DataObject;
                if (dataMoveReplicationConstraintParameter != dataObject7.DataMoveReplicationConstraint)
                {
                    TDataObject dataObject8 = this.DataObject;
                    DataMoveReplicationConstraintParameter dataMoveReplicationConstraint2 = dataObject8.DataMoveReplicationConstraint;
                    TDataObject dataObject9 = this.DataObject;
                    base.WriteError(new ConstraintErrorException(dataMoveReplicationConstraint2, dataObject9.Identity.ToString()), ErrorCategory.InvalidOperation, this.Identity);
                }
            }
            TDataObject dataObject10 = this.DataObject;

            if (dataObject10.IsChanged(DatabaseSchema.CircularLoggingEnabled))
            {
                TDataObject    dataObject11   = this.DataObject;
                DatabaseCopy[] databaseCopies = dataObject11.GetDatabaseCopies();
                if (databaseCopies != null && databaseCopies.Length == 1)
                {
                    TDataObject dataObject12 = this.DataObject;
                    this.WriteWarning(Strings.WarningOperationOnDBWithJetCircularLogging(dataObject12.Identity.ToString()));
                }
            }
            TaskLogger.LogExit();
        }
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            if (base.HasErrors)
            {
                TaskLogger.LogExit();
                return;
            }
            this.m_databaseCopy = this.DataObject;
            DatabaseTasksHelper.ValidateDatabaseCopyActionTask(this.m_databaseCopy, false, true, base.DataSession, this.RootId, new Task.TaskErrorLoggingDelegate(base.WriteError), Strings.ErrorMailboxDatabaseNotUnique(this.Identity.ToString()), new LocalizedString?(Strings.ErrorSingleDatabaseCopy(this.Identity.ToString())), out this.m_server);
            Database database = this.DataObject.GetDatabase <Database>();

            if (database != null)
            {
                MapiTaskHelper.VerifyDatabaseIsWithinScope(base.SessionSettings, database, new Task.ErrorLoggerDelegate(base.WriteError));
            }
        }
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     if (base.HasErrors)
     {
         TaskLogger.LogExit();
         return;
     }
     this.m_server = (Server)base.GetDataObject <Server>(this.MailboxServer, base.DataSession, null, new LocalizedString?(Strings.ErrorMailboxServerNotFound(this.MailboxServer.ToString())), new LocalizedString?(Strings.ErrorMailboxServerNotUnique(this.MailboxServer.ToString())));
     if (!this.m_server.IsE14OrLater)
     {
         base.WriteError(new InvalidOperationException(Strings.ErrorServerNotE14OrLater(this.MailboxServer.ToString())), ErrorCategory.InvalidOperation, this.MailboxServer);
     }
     if (!Datacenter.IsMicrosoftHostedOnly(true) && this.DataObject.IsPublicFolderDatabase)
     {
         base.WriteError(new InvalidOperationException(Strings.ErrorInvalidOperationOnAddDBCopyForPublicFolder(this.DataObject.Name)), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     if (this.DataObject.Recovery)
     {
         base.WriteError(new InvalidOperationException(Strings.ErrorInvalidOperationOnAddDBCopyForRecoveryDB(this.DataObject.Name)), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     this.m_databaseCopies = this.DataObject.GetDatabaseCopies();
     if (this.m_databaseCopies == null || this.m_databaseCopies.Length == 0)
     {
         base.WriteError(new CopyConfigurationErrorException(Strings.ErrorCouldNotReadDatabaseCopy(this.DataObject.Name)), ErrorCategory.ReadError, this.DataObject.Identity);
     }
     else
     {
         if (this.DataObject.AllDatabaseCopies.Length == 1)
         {
             this.m_firstCopy = true;
             if (this.DataObject.CircularLoggingEnabled)
             {
                 base.WriteError(new InvalidOperationException(Strings.ErrorInvalidAddOperationOnDBCopyForCircularLoggingEnabledDB(this.DataObject.Name)), ErrorCategory.InvalidOperation, this.DataObject.Identity);
             }
         }
         foreach (DatabaseCopy databaseCopy in this.m_databaseCopies)
         {
             if (databaseCopy.HostServer != null && databaseCopy.HostServer.ObjectGuid == this.m_server.Guid)
             {
                 base.WriteError(new DbCopyAlreadyHostedOnServerException(this.DataObject.Identity.ToString(), this.m_server.Identity.ToString()), ErrorCategory.InvalidOperation, this.DataObject.Identity);
             }
         }
         foreach (DatabaseCopy databaseCopy2 in this.DataObject.InvalidDatabaseCopies)
         {
             if (databaseCopy2.Name.Equals(this.m_server.Name, StringComparison.OrdinalIgnoreCase))
             {
                 this.m_invalidDbCopy = databaseCopy2;
                 break;
             }
         }
     }
     if (base.Fields["ActivationPreference"] != null && (this.ActivationPreference <1U || (ulong)this.ActivationPreference> (ulong)((long)(this.DataObject.AllDatabaseCopies.Length + 1))))
     {
         base.WriteError(new ArgumentException(Strings.ErrorActivationPreferenceInvalid(this.ActivationPreference, this.DataObject.AllDatabaseCopies.Length + 1)), ErrorCategory.InvalidArgument, null);
     }
     this.RcrValidation();
     base.VerifyIsWithinScopes((IConfigurationSession)base.DataSession, this.m_server, true, new DataAccessTask <Database> .ADObjectOutOfScopeString(Strings.ErrorServerOutOfScope));
     MapiTaskHelper.VerifyDatabaseIsWithinScope(base.SessionSettings, this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError));
     TaskLogger.LogExit();
 }
예제 #8
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            if ("Linked" == base.ParameterSetName)
            {
                try
                {
                    NetworkCredential userForestCredential = (this.LinkedCredential == null) ? null : this.LinkedCredential.GetNetworkCredential();
                    this.linkedUserSid = MailboxTaskHelper.GetAccountSidFromAnotherForest(this.LinkedMasterAccount, this.LinkedDomainController, userForestCredential, this.ResourceForestSession, new MailboxTaskHelper.GetUniqueObject(base.GetDataObject <ADUser>), new Task.ErrorLoggerDelegate(base.ThrowTerminatingError));
                }
                catch (PSArgumentException exception)
                {
                    base.ThrowTerminatingError(exception, ErrorCategory.InvalidArgument, this.LinkedCredential);
                }
            }
            if (this.ManagedFolderMailboxPolicy != null)
            {
                ManagedFolderMailboxPolicy managedFolderMailboxPolicy = (ManagedFolderMailboxPolicy)base.GetDataObject <ManagedFolderMailboxPolicy>(this.ManagedFolderMailboxPolicy, this.TenantConfigurationSession, null, new LocalizedString?(Strings.ErrorManagedFolderMailboxPolicyNotFound(this.ManagedFolderMailboxPolicy.ToString())), new LocalizedString?(Strings.ErrorManagedFolderMailboxPolicyNotUnique(this.ManagedFolderMailboxPolicy.ToString())));
                this.elcPolicyId = (ADObjectId)managedFolderMailboxPolicy.Identity;
            }
            if (this.RetentionPolicy != null)
            {
                if (SharedConfiguration.IsDehydratedConfiguration(base.CurrentOrganizationId))
                {
                    base.WriteError(new LocalizedException(Strings.ErrorLinkOpOnDehydratedTenant("RetentionPolicy")), ExchangeErrorCategory.Client, null);
                }
                RetentionPolicy retentionPolicy = (RetentionPolicy)base.GetDataObject <RetentionPolicy>(this.RetentionPolicy, this.TenantConfigurationSession, null, new LocalizedString?(Strings.ErrorRetentionPolicyNotFound(this.RetentionPolicy.ToString())), new LocalizedString?(Strings.ErrorRetentionPolicyNotUnique(this.RetentionPolicy.ToString())));
                this.retentionPolicyId = retentionPolicy.Id;
            }
            if (this.ActiveSyncMailboxPolicy != null)
            {
                MobileMailboxPolicy mobileMailboxPolicy = (MobileMailboxPolicy)base.GetDataObject <MobileMailboxPolicy>(this.ActiveSyncMailboxPolicy, this.TenantConfigurationSession, null, new LocalizedString?(Strings.ErrorMobileMailboxPolicyNotFound(this.ActiveSyncMailboxPolicy.ToString())), new LocalizedString?(Strings.ErrorMobileMailboxPolicyNotUnique(this.ActiveSyncMailboxPolicy.ToString())));
                this.mobilePolicyId = (ADObjectId)mobileMailboxPolicy.Identity;
            }
            if (this.AddressBookPolicy != null)
            {
                AddressBookMailboxPolicy addressBookMailboxPolicy = (AddressBookMailboxPolicy)base.GetDataObject <AddressBookMailboxPolicy>(this.AddressBookPolicy, this.TenantConfigurationSession, null, new LocalizedString?(Strings.ErrorAddressBookMailboxPolicyNotFound(this.AddressBookPolicy.ToString())), new LocalizedString?(Strings.ErrorAddressBookMailboxPolicyNotUnique(this.AddressBookPolicy.ToString())), ExchangeErrorCategory.Client);
                this.addressBookPolicyId = (ADObjectId)addressBookMailboxPolicy.Identity;
            }
            MailboxTaskHelper.ValidateMailboxIsDisconnected(this.GlobalCatalogSession, this.DataObject.MailboxGuid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
            if (!this.Archive)
            {
                ConnectMailbox.CheckLegacyDNNotInUse(this.DataObject.Identity, this.DataObject.LegacyDN, this.GlobalCatalogSession, new Task.ErrorLoggerDelegate(base.WriteError));
            }
            if (this.User != null)
            {
                this.userToConnect = (ADUser)base.GetDataObject <ADUser>(this.User, this.RecipientSession, null, new LocalizedString?(Strings.ErrorRecipientNotFound(this.User.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(this.User.ToString())));
                if (this.Archive)
                {
                    ConnectMailbox.CheckUserForArchive(this.DataObject, this.GlobalCatalogSession, new Task.ErrorLoggerDelegate(base.WriteError), this.userToConnect, this.OwnerMailboxDatabase, this.AllowLegacyDNMismatch);
                }
                else if (RecipientType.User != this.userToConnect.RecipientType)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorNoMatchedUserTypeFound(RecipientType.User.ToString(), this.User.ToString(), this.userToConnect.RecipientType.ToString())), ErrorCategory.InvalidArgument, this.User);
                }
            }
            else if (!this.Archive)
            {
                if ("ValidateOnly" == base.ParameterSetName)
                {
                    this.matchedUsers = this.FindMatchedUser(this.DataObject, null);
                }
                else
                {
                    this.matchedUsers = this.FindMatchedUser(this.DataObject, new bool?("User" == base.ParameterSetName));
                }
                if ("ValidateOnly" != base.ParameterSetName)
                {
                    if (this.matchedUsers.Length == 0)
                    {
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorNoMatchedUserFound), ErrorCategory.InvalidArgument, this.Identity);
                    }
                    else if (this.matchedUsers.Length > 1)
                    {
                        this.WriteWarning(Strings.ErrorMultipleMatchedUser(this.Identity.ToString()));
                        this.needListMatchingUser = true;
                    }
                    else
                    {
                        this.userToConnect = (ADUser)this.matchedUsers[0];
                        this.userToConnect = (ADUser)this.RecipientSession.Read(this.userToConnect.Id);
                        if (this.userToConnect == null)
                        {
                            base.WriteError(new MdbAdminTaskException(Strings.ErrorNoMatchedUserFound), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        if (this.Archive)
                        {
                            ConnectMailbox.CheckUserForArchive(this.DataObject, this.GlobalCatalogSession, new Task.ErrorLoggerDelegate(base.WriteError), this.userToConnect, this.OwnerMailboxDatabase, this.AllowLegacyDNMismatch);
                        }
                    }
                }
            }
            else
            {
                this.userToConnect = this.FindArchiveUser(this.DataObject, this.RecipientSession, new Task.TaskErrorLoggingDelegate(base.WriteError));
                ConnectMailbox.CheckUserForArchive(this.DataObject, this.GlobalCatalogSession, new Task.ErrorLoggerDelegate(base.WriteError), this.userToConnect, this.OwnerMailboxDatabase, this.AllowLegacyDNMismatch);
            }
            if (this.userToConnect != null && !this.Archive)
            {
                if ("User" == base.ParameterSetName)
                {
                    if ((this.userToConnect.UserAccountControl & UserAccountControlFlags.AccountDisabled) != UserAccountControlFlags.None && this.DataObject.MailboxType == StoreMailboxType.Private)
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorAccountDisabledForUserMailbox), ErrorCategory.InvalidArgument, this.userToConnect);
                    }
                }
                else if ((this.userToConnect.UserAccountControl & UserAccountControlFlags.AccountDisabled) == UserAccountControlFlags.None)
                {
                    base.WriteError(new RecipientTaskException(Strings.ErrorAccountEnabledForNonUserMailbox), ErrorCategory.InvalidArgument, this.userToConnect);
                }
                if (!string.IsNullOrEmpty(this.Alias))
                {
                    this.alias = this.Alias;
                }
                else
                {
                    this.alias = RecipientTaskHelper.GenerateUniqueAlias(this.globalCatalogSession, this.userToConnect.OrganizationId, this.userToConnect.Name, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                }
            }
            if (this.Archive && this.userToConnect.ManagedFolderMailboxPolicy != null)
            {
                base.WriteError(new MdbAdminTaskException(Strings.ErrorNoArchiveWithManagedFolder(this.userToConnect.Name)), ErrorCategory.InvalidData, this.Identity);
            }
            if (this.DataObject.IsArchiveMailbox != null && this.Archive != this.DataObject.IsArchiveMailbox.Value)
            {
                if (this.Archive)
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorDisconnectedMailboxNotArchive(this.Identity.ToString(), this.userToConnect.Name)), ErrorCategory.InvalidArgument, this.Identity);
                }
                else
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorDisconnectedMailboxNotPrimary(this.Identity.ToString(), this.userToConnect.Name)), ErrorCategory.InvalidArgument, this.Identity);
                }
            }
            ADSessionSettings sessionSettings = ADSessionSettings.FromCustomScopeSet(base.ScopeSet, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true);

            MapiTaskHelper.VerifyDatabaseIsWithinScope(sessionSettings, this.OwnerMailboxDatabase, new Task.ErrorLoggerDelegate(base.WriteError));
            TaskLogger.LogExit();
        }