Ejemplo n.º 1
0
        protected override IConfigDataProvider CreateSession()
        {
            OrganizationIdParameter organization = null;

            if (MapiTaskHelper.IsDatacenter)
            {
                organization = MapiTaskHelper.ResolveTargetOrganizationIdParameter(null, this.Identity, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError), new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            }
            base.CurrentOrganizationId = MapiTaskHelper.ResolveTargetOrganization(base.DomainController, organization, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
            if (this.publicFolderDataProvider == null || base.CurrentOrganizationId != this.publicFolderDataProvider.CurrentOrganizationId)
            {
                if (this.publicFolderDataProvider != null)
                {
                    this.publicFolderDataProvider.Dispose();
                    this.publicFolderDataProvider = null;
                }
                try
                {
                    this.publicFolderDataProvider = new PublicFolderDataProvider(this.ConfigurationSession, "Remove-PublicFolder", Guid.Empty);
                }
                catch (AccessDeniedException exception)
                {
                    base.WriteError(exception, ErrorCategory.PermissionDenied, this.Identity);
                }
            }
            return(this.publicFolderDataProvider);
        }
 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();
     }
 }
Ejemplo n.º 3
0
        protected override void InternalValidate()
        {
            base.InternalValidate();
            if (!this.Identity.IsUnique())
            {
                base.WriteError(new NonUniqueEventCategoryInputException(), ErrorCategory.InvalidData, this.Identity);
            }
            ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(null, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 148, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\EventLog\\SetEventLogLevel.cs");
            EventCategoryIdentity         eventCategoryIdentity        = null;

            if (this.Identity.ToString() != null)
            {
                eventCategoryIdentity = EventCategoryIdentity.Parse(this.Identity.ToString());
            }
            Server obj;

            if (eventCategoryIdentity == null || string.IsNullOrEmpty(eventCategoryIdentity.Server))
            {
                obj = topologyConfigurationSession.FindLocalServer();
            }
            else
            {
                ServerIdParameter serverIdParameter = ServerIdParameter.Parse(eventCategoryIdentity.Server);
                obj = (Server)base.GetDataObject <Server>(serverIdParameter, topologyConfigurationSession, null, null, new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())));
            }
            ADSessionSettings sessionSettings = ADSessionSettings.FromCustomScopeSet(base.ScopeSet, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId, true);

            MapiTaskHelper.VerifyIsWithinConfigWriteScope(sessionSettings, obj, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError));
        }
Ejemplo n.º 4
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     base.InternalValidate();
     MapiTaskHelper.VerifyDatabaseAndItsOwningServerInScope(base.SessionSettings, this.DataObject, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError));
     TaskLogger.LogExit();
 }
Ejemplo n.º 5
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);
                }
            }
        }
Ejemplo n.º 6
0
        private static void SaveArchiveSecurityDescriptor(ADUser mailbox, IConfigDataProvider writableAdSession, RawSecurityDescriptor rawSd, Task.TaskVerboseLoggingDelegate logVerbose, Task.ErrorLoggerDelegate logError)
        {
            ADObjectId adobjectId = mailbox.ArchiveDatabase ?? mailbox.Database;
            MailboxId  mailboxId  = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), mailbox.ArchiveGuid);

            try
            {
                ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(adobjectId.ObjectGuid);
                using (MapiMessageStoreSession mapiMessageStoreSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, PermissionTaskHelper.CalcuteSystemAttendantMailboxLegacyDistingushName(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn)))
                {
                    logVerbose(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), mapiMessageStoreSession.ServerName));
                    mapiMessageStoreSession.ForceStoreToRefreshMailbox(mailboxId);
                }
            }
            catch (FormatException)
            {
                logError(new TaskInvalidOperationException(Strings.ErrorInvalidServerLegacyDistinguishName(mailbox.DistinguishedName.ToString())), ExchangeErrorCategory.ServerOperation, null);
            }
            catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException)
            {
                logVerbose(Strings.VerboseArchiveNotExistInStore(mailbox.Name));
                PermissionTaskHelper.SaveAdSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError);
            }
            catch (LocalizedException exception)
            {
                logError(new SetArchivePermissionException(mailbox.Name, exception), ExchangeErrorCategory.ServerOperation, null);
            }
        }
Ejemplo n.º 7
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();
 }
        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);
            }
        }
Ejemplo n.º 9
0
 protected override void InternalBeginProcessing()
 {
     if (MapiTaskHelper.IsDatacenter)
     {
         this.Organization = MapiTaskHelper.ResolveTargetOrganizationIdParameter(this.Organization, null, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError), new Task.TaskWarningLoggingDelegate(this.WriteWarning));
     }
     base.InternalBeginProcessing();
 }
Ejemplo n.º 10
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();
     try
     {
         if (MapiTaskHelper.IsDatacenter)
         {
             base.CurrentOrganizationId = MapiTaskHelper.ResolveTargetOrganization(base.DomainController, this.Organization, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
             base.RescopeToOrgId(base.CurrentOrganizationId);
             base.OrganizationId = base.CurrentOrganizationId;
         }
         else
         {
             base.OrganizationId = OrganizationId.ForestWideOrgId;
         }
         this.DisallowPublicFolderMoveDuringFinalization();
         this.targetMailboxUser = (ADUser)base.GetDataObject <ADUser>(this.TargetMailbox, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.TargetMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.TargetMailbox.ToString())), ExchangeErrorCategory.Client);
         TenantPublicFolderConfigurationCache.Instance.RemoveValue(base.CurrentOrganizationId);
         TenantPublicFolderConfiguration value = TenantPublicFolderConfigurationCache.Instance.GetValue(base.CurrentOrganizationId);
         if (value.GetLocalMailboxRecipient(this.targetMailboxUser.ExchangeGuid) == null)
         {
             base.WriteError(new RecipientTaskException(Strings.ErrorCannotMovePublicFolderIntoNonPublicFolderMailbox), ErrorCategory.InvalidArgument, this.targetMailboxUser);
         }
         string text = this.GetSourceMailboxGuid().ToString();
         this.sourceMailboxUser = (ADUser)base.GetDataObject <ADUser>(MailboxIdParameter.Parse(text), base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxAddressNotFound(text)), new LocalizedString?(Strings.ErrorMailboxAddressNotFound(text)), ExchangeErrorCategory.Client);
         if (this.sourceMailboxUser.ExchangeGuid == this.targetMailboxUser.ExchangeGuid)
         {
             base.WriteError(new RecipientTaskException(Strings.ErrorCannotMovePublicFolderIntoSameMailbox), ErrorCategory.InvalidArgument, this.targetMailboxUser);
         }
         if (!string.IsNullOrEmpty(base.Name))
         {
             base.ValidateName();
             base.RequestName = base.Name;
         }
         else
         {
             base.RequestName = "PublicFolderMove";
         }
         ADObjectId mdbId         = null;
         ADObjectId mdbServerSite = null;
         base.Flags = (RequestFlags.IntraOrg | this.LocateAndChooseMdb(value.GetLocalMailboxRecipient(this.sourceMailboxUser.ExchangeGuid).Database, value.GetLocalMailboxRecipient(this.targetMailboxUser.ExchangeGuid).Database, this.sourceMailboxUser, this.targetMailboxUser, this.targetMailboxUser, out mdbId, out mdbServerSite));
         if (base.WorkloadType == RequestWorkloadType.None)
         {
             base.WorkloadType = RequestWorkloadType.Local;
         }
         base.MdbId         = mdbId;
         base.MdbServerSite = mdbServerSite;
         base.WriteVerbose(Strings.RequestQueueIdentified(base.MdbId.Name));
         this.CheckRequestNameAvailability(null, null, false, MRSRequestType.PublicFolderMove, this.Organization, false);
         base.WriteVerbose(Strings.RequestNameAvailabilityComplete);
         base.InternalValidate();
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
Ejemplo n.º 12
0
 protected override OrganizationId ResolveCurrentOrganization()
 {
     if (MapiTaskHelper.IsDatacenter)
     {
         OrganizationIdParameter organization = MapiTaskHelper.ResolveTargetOrganizationIdParameter(base.Organization, this.Identity, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError), new Task.TaskWarningLoggingDelegate(this.WriteWarning));
         return(MapiTaskHelper.ResolveTargetOrganization(base.DomainController, organization, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId));
     }
     return(base.CurrentOrganizationId ?? base.ExecutingUserOrganizationId);
 }
Ejemplo n.º 13
0
        protected override ADUser PrepareMailboxUser()
        {
            OrganizationIdParameter organization = null;

            if (MapiTaskHelper.IsDatacenter)
            {
                organization = MapiTaskHelper.ResolveTargetOrganizationIdParameter(null, this.Identity, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError), new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            }
            base.CurrentOrganizationId = MapiTaskHelper.ResolveTargetOrganization(base.DomainController, organization, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
            base.Identity = PublicFolderPermissionTaskHelper.GetMailboxFolderIdParameterForPublicFolder(this.ConfigurationSession, this.Identity, Guid.Empty, null, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.WriteError));
            return(base.PrepareMailboxUser());
        }
Ejemplo n.º 14
0
        private void ResolveDatabaseAndServer()
        {
            ActiveManager activeManagerInstance = ActiveManager.GetActiveManagerInstance();

            if (this.Server != null)
            {
                this.server = MapiTaskHelper.GetMailboxServer(this.Server, (ITopologyConfigurationSession)this.ConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError));
            }
            else if (this.Identity != null)
            {
                DatabaseIdParameter identity = this.Identity;
                identity.AllowLegacy = false;
                Database          database = (Database)base.GetDataObject <Database>(identity, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(identity.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(identity.ToString())));
                ServerIdParameter serverIdParameter;
                if (this.CopyOnServer != null)
                {
                    serverIdParameter = this.CopyOnServer;
                }
                else
                {
                    if (database.Server == null)
                    {
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Database).Name, identity.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, database);
                    }
                    DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(database.Guid);
                    serverIdParameter = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);
                }
                this.server = (Server)base.GetDataObject <Server>(serverIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));
                if (!this.server.IsExchange2007OrLater || !this.server.IsMailboxServer)
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorLocalServerIsNotMailboxServer), ErrorCategory.InvalidArgument, this.server);
                }
                this.databases = new List <Database>(new Database[]
                {
                    database
                });
            }
            else
            {
                ServerIdParameter serverIdParameter2 = new ServerIdParameter();
                this.server = (Server)base.GetDataObject <Server>(serverIdParameter2, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorLocalMachineIsNotExchangeServer), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter2.ToString())));
                if (!this.server.IsExchange2007OrLater || !this.server.IsMailboxServer)
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorLocalServerIsNotMailboxServer), ErrorCategory.InvalidArgument, this.server);
                }
            }
            if (this.databases.Count == 0)
            {
                this.databases = StoreCommon.PopulateDatabasesFromServer(activeManagerInstance, this.server, this.IncludePassive);
            }
        }
Ejemplo n.º 15
0
        public static void SaveMailboxSecurityDescriptor(ADUser mailbox, ActiveDirectorySecurity adSecurity, IConfigDataProvider writableAdSession, ref MapiMessageStoreSession storeSession, Task.TaskVerboseLoggingDelegate logVerbose, Task.ErrorLoggerDelegate logError)
        {
            if (writableAdSession == null)
            {
                throw new ArgumentException("writableAdSession");
            }
            RawSecurityDescriptor rawSd = new RawSecurityDescriptor(adSecurity.GetSecurityDescriptorBinaryForm(), 0);

            PermissionTaskHelper.SaveAdSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError);
            string text = null;

            try
            {
                ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(mailbox.Database.ObjectGuid);
                text = serverForDatabase.ServerFqdn;
                if (storeSession == null)
                {
                    storeSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, PermissionTaskHelper.CalcuteSystemAttendantMailboxLegacyDistingushName(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn));
                }
                else
                {
                    storeSession.RedirectServer(serverForDatabase.ServerLegacyDN, Fqdn.Parse(serverForDatabase.ServerFqdn));
                }
                MailboxId mailboxId = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(mailbox.Database), mailbox.ExchangeGuid);
                logVerbose(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), storeSession.ServerName));
                storeSession.Administration.PurgeCachedMailboxObject(mailboxId.MailboxGuid);
            }
            catch (DatabaseNotFoundException)
            {
                logVerbose(Strings.ErrorMailboxDatabaseNotFound(mailbox.Database.ToString()));
            }
            catch (MapiExceptionNetworkError)
            {
                logVerbose(Strings.ErrorFailedToConnectToStore((text != null) ? text : string.Empty));
            }
            catch (FormatException)
            {
                logVerbose(Strings.ErrorInvalidServerLegacyDistinguishName(mailbox.DistinguishedName.ToString()));
            }
            catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException)
            {
                logVerbose(Strings.VerboseMailboxNotExistInStore(mailbox.DistinguishedName));
            }
            if (mailbox.HasLocalArchive)
            {
                PermissionTaskHelper.SaveArchiveSecurityDescriptor(mailbox, writableAdSession, rawSd, logVerbose, logError);
            }
        }
Ejemplo n.º 16
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.DataObject
     });
     base.InternalProcessRecord();
     if (this.recoverArchive && this.DataObject.ArchiveDatabase != null)
     {
         MailboxDatabase database = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(new DatabaseIdParameter(this.DataObject.ArchiveDatabase), base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(this.DataObject.ArchiveDatabase.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(this.DataObject.ArchiveDatabase.ToString())));
         using (MapiAdministrationSession adminSession = MapiTaskHelper.GetAdminSession(RecipientTaskHelper.GetActiveManagerInstance(), this.DataObject.ArchiveDatabase.ObjectGuid))
         {
             ConnectMailbox.UpdateSDAndRefreshMailbox(adminSession, this.DataObject, database, this.DataObject.ArchiveGuid, null, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning));
         }
     }
     TaskLogger.LogExit();
 }
Ejemplo n.º 17
0
        internal IEnumerable <DatabaseEvent> ReadEvents(MapiSession mapiSession, Database database, long startCounter, Restriction restriction, bool includeMoveDestinationEvents, int resultSize)
        {
            if (mapiSession == null)
            {
                throw new ArgumentException("mapiSession");
            }
            if (database == null)
            {
                throw new ArgumentException("database");
            }
            int  count      = 0;
            long endCounter = (0L < startCounter) ? (startCounter - 1L) : 0L;

            MapiEvent[]      events       = null;
            DatabaseId       databaseId   = MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(database);
            MapiEventManager eventManager = MapiEventManager.Create(mapiSession.Administration, Guid.NewGuid(), databaseId.Guid);

            for (;;)
            {
                startCounter = endCounter + 1L;
                ReadEventsFlags flags = includeMoveDestinationEvents ? ReadEventsFlags.IncludeMoveDestinationEvents : ReadEventsFlags.None;
                mapiSession.InvokeWithWrappedException(delegate()
                {
                    events = eventManager.ReadEvents(startCounter, (0 < resultSize) ? resultSize : 1000, 0, restriction, flags, out endCounter);
                }, Strings.ErrorCannotReadDatabaseEvents(databaseId.ToString()), databaseId);
                foreach (MapiEvent mapiEvent in events)
                {
                    yield return(new DatabaseEvent(mapiEvent, databaseId, this.server, database.Server.ObjectGuid == this.server.Guid));

                    count++;
                    if (0 < resultSize && count == resultSize)
                    {
                        goto Block_6;
                    }
                }
                if (endCounter == startCounter)
                {
                    goto Block_8;
                }
            }
Block_6:
            yield break;
Block_8:
            yield break;
        }
Ejemplo n.º 18
0
 internal static void UpdateSDAndRefreshMailbox(MapiAdministrationSession mapiAdministrationSession, ADUser userToConnect, MailboxDatabase database, Guid mailboxGuid, string parameterSetName, Task.TaskVerboseLoggingDelegate verboseLogger, Task.TaskWarningLoggingDelegate warningLogger)
 {
     ConnectMailbox.UpdateMailboxSecurityDescriptor(userToConnect.Sid, userToConnect, mapiAdministrationSession, database, mailboxGuid, parameterSetName, verboseLogger);
     try
     {
         mapiAdministrationSession.ForceStoreToRefreshMailbox(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(database), mailboxGuid));
     }
     catch (FailedToRefreshMailboxException ex)
     {
         TaskLogger.Trace("An exception is caught and ignored when refreshing the mailbox '{0}'. Exception: {1}", new object[]
         {
             mailboxGuid,
             ex.Message
         });
         warningLogger(Strings.WarningReplicationLatency);
     }
     try
     {
         mapiAdministrationSession.SyncMailboxWithDS(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectToDatabaseId(database), mailboxGuid));
     }
     catch (DataSourceTransientException ex2)
     {
         TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
         {
             ex2
         });
         warningLogger(ex2.LocalizedString);
     }
     catch (DataSourceOperationException ex3)
     {
         TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
         {
             ex3
         });
         warningLogger(ex3.LocalizedString);
     }
     catch (ArgumentNullException ex4)
     {
         TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
         {
             ex4
         });
         warningLogger(Strings.ErrorNoDatabaseInfor);
     }
 }
Ejemplo n.º 19
0
        protected sealed override IConfigDataProvider CreateSession()
        {
            OrganizationIdParameter organization = null;

            if (MapiTaskHelper.IsDatacenter)
            {
                organization = MapiTaskHelper.ResolveTargetOrganizationIdParameter(this.Organization, this.Identity, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError), new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            }
            base.CurrentOrganizationId = MapiTaskHelper.ResolveTargetOrganization(base.DomainController, organization, base.RootOrgContainerId, base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
            this.rootId = null;
            if ((this.Recurse.IsPresent || this.GetChildren.IsPresent) && this.Identity != null)
            {
                this.rootId   = this.Identity.PublicFolderId;
                this.Identity = null;
            }
            if (this.publicFolderDataProvider == null || base.CurrentOrganizationId != this.publicFolderDataProvider.CurrentOrganizationId)
            {
                if (this.publicFolderDataProvider != null)
                {
                    this.publicFolderDataProvider.Dispose();
                    this.publicFolderDataProvider = null;
                }
                Guid mailboxGuid = Guid.Empty;
                if (base.Fields.IsModified("Mailbox"))
                {
                    ADUser aduser = (ADUser)base.GetDataObject <ADUser>(this.Mailbox, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.Mailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.Mailbox.ToString())), ExchangeErrorCategory.Client);
                    this.VerifyIsPublicFolderMailbox(aduser);
                    mailboxGuid = aduser.ExchangeGuid;
                }
                try
                {
                    this.publicFolderDataProvider = new PublicFolderDataProvider(this.ConfigurationSession, "Get-PublicFolder", mailboxGuid);
                }
                catch (AccessDeniedException exception)
                {
                    base.WriteError(exception, ErrorCategory.PermissionDenied, this.Identity);
                }
            }
            if (this.ResidentFolders.IsPresent)
            {
                this.contentMailboxGuid = this.publicFolderDataProvider.PublicFolderSession.MailboxGuid;
                this.inputFilter        = new ComparisonFilter(ComparisonOperator.Equal, FolderSchema.ReplicaListBinary, this.contentMailboxGuid.ToByteArray());
            }
            return(this.publicFolderDataProvider);
        }
        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));
            }
        }
Ejemplo n.º 21
0
        protected override IConfigDataProvider CreateSession()
        {
            OrganizationIdParameter organization = null;

            if (MapiTaskHelper.IsDatacenter)
            {
                organization = MapiTaskHelper.ResolveTargetOrganizationIdParameter(null, this.Identity, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError), new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            }
            base.CurrentOrganizationId = MapiTaskHelper.ResolveTargetOrganization(base.DomainController, organization, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
            if (this.publicFolderDataProvider == null || base.CurrentOrganizationId != this.publicFolderDataProvider.CurrentOrganizationId)
            {
                if (this.OverrideContentMailbox != null)
                {
                    IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.PartiallyConsistent, null, base.SessionSettings, 337, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\MapiTasks\\PublicFolder\\SetPublicFolder.cs");
                    ADUser            aduser = (ADUser)base.GetDataObject <ADUser>(this.OverrideContentMailbox, tenantOrRootOrgRecipientSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(this.OverrideContentMailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(this.OverrideContentMailbox.ToString())));
                    if (aduser == null || aduser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox)
                    {
                        base.WriteError(new RecipientTaskException(Strings.ErrorInvalidContentMailbox(this.OverrideContentMailbox.ToString())), ErrorCategory.InvalidArgument, aduser);
                    }
                    if (TenantPublicFolderConfigurationCache.Instance.GetValue(base.CurrentOrganizationId).GetLocalMailboxRecipient(aduser.ExchangeGuid) == null)
                    {
                        TenantPublicFolderConfigurationCache.Instance.RemoveValue(base.CurrentOrganizationId);
                    }
                    this.contentMailboxGuid = aduser.ExchangeGuid;
                }
                if (this.publicFolderDataProvider != null)
                {
                    this.publicFolderDataProvider.Dispose();
                    this.publicFolderDataProvider = null;
                }
                try
                {
                    this.publicFolderDataProvider = new PublicFolderDataProvider(this.ConfigurationSession, "Set-PublicFolder", Guid.Empty);
                }
                catch (AccessDeniedException exception)
                {
                    base.WriteError(exception, ErrorCategory.PermissionDenied, this.Identity);
                }
            }
            return(this.publicFolderDataProvider);
        }
Ejemplo n.º 22
0
        public void Refresh(ADUser mailbox, IRecipientSession writableAdSession)
        {
            if (mailbox == null)
            {
                throw new ArgumentNullException("mailbox");
            }
            if (writableAdSession == null)
            {
                throw new ArgumentNullException("writableAdSession");
            }
            MapiMessageStoreSession mapiMessageStoreSession = null;

            try
            {
                ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(mailbox.Database.ObjectGuid);
                mapiMessageStoreSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, TeamMailboxSecurityRefresher.CalculateSystemAttendantMailboxLegacyDistingushName(serverForDatabase.ServerLegacyDN), Fqdn.Parse(serverForDatabase.ServerFqdn));
                MailboxId mailboxId = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(mailbox.Database), mailbox.ExchangeGuid);
                try
                {
                    mapiMessageStoreSession.Administration.PurgeCachedMailboxObject(mailboxId.MailboxGuid);
                }
                catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex)
                {
                    throw new ObjectNotFoundException(new LocalizedString(ex.ToString()));
                }
                catch (DatabaseUnavailableException ex2)
                {
                    throw new ObjectNotFoundException(new LocalizedString(ex2.ToString()));
                }
            }
            finally
            {
                if (mapiMessageStoreSession != null)
                {
                    mapiMessageStoreSession.Dispose();
                }
            }
        }
Ejemplo n.º 23
0
        protected override ADUser PrepareMailboxUser()
        {
            OrganizationIdParameter organization = null;
            ADUser aduser = null;
            Guid   publicFolderMailboxGuid = Guid.Empty;

            if (MapiTaskHelper.IsDatacenter)
            {
                organization = MapiTaskHelper.ResolveTargetOrganizationIdParameter(null, this.Identity, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError), new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            }
            base.CurrentOrganizationId = MapiTaskHelper.ResolveTargetOrganization(base.DomainController, organization, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
            if (base.Fields.IsModified("Mailbox"))
            {
                aduser = (ADUser)base.GetDataObject <ADUser>(this.Mailbox, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.Mailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.Mailbox.ToString())), ExchangeErrorCategory.Client);
                if (aduser == null || aduser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox)
                {
                    base.WriteError(new ObjectNotFoundException(Strings.PublicFolderMailboxNotFound), ExchangeErrorCategory.Client, aduser);
                }
                publicFolderMailboxGuid = aduser.ExchangeGuid;
            }
            base.Identity = PublicFolderPermissionTaskHelper.GetMailboxFolderIdParameterForPublicFolder(this.ConfigurationSession, this.Identity, publicFolderMailboxGuid, aduser, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.WriteError));
            return(base.PrepareMailboxUser());
        }
Ejemplo n.º 24
0
        protected sealed override IConfigDataProvider CreateSession()
        {
            OrganizationIdParameter organization = null;

            if (MapiTaskHelper.IsDatacenter)
            {
                organization = MapiTaskHelper.ResolveTargetOrganizationIdParameter(this.Organization, this.Identity, base.CurrentOrganizationId, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError), new Task.TaskWarningLoggingDelegate(this.WriteWarning));
            }
            base.CurrentOrganizationId = MapiTaskHelper.ResolveTargetOrganization(base.DomainController, organization, ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), base.CurrentOrganizationId, base.ExecutingUserOrganizationId);
            if (this.publicFolderStatisticsDataProvider == null || base.CurrentOrganizationId != this.publicFolderStatisticsDataProvider.CurrentOrganizationId)
            {
                if (this.publicFolderStatisticsDataProvider != null)
                {
                    this.publicFolderStatisticsDataProvider.Dispose();
                    this.publicFolderStatisticsDataProvider = null;
                }
                Guid mailboxGuid = Guid.Empty;
                if (base.Fields.IsModified("MailboxInformation"))
                {
                    ADUser aduser = (ADUser)base.GetDataObject <ADUser>(this.Mailbox, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.Mailbox.ToString())), new LocalizedString?(Strings.ErrorMailboxAddressNotFound(this.Mailbox.ToString())), ExchangeErrorCategory.Client);
                    if (aduser == null || aduser.RecipientTypeDetails != RecipientTypeDetails.PublicFolderMailbox)
                    {
                        base.WriteError(new ObjectNotFoundException(Strings.PublicFolderMailboxNotFound), ExchangeErrorCategory.Client, aduser);
                    }
                    mailboxGuid = aduser.ExchangeGuid;
                }
                try
                {
                    this.publicFolderStatisticsDataProvider = new PublicFolderStatisticsDataProvider(this.ConfigurationSession, "Get-PublicFolderStatistics", mailboxGuid);
                }
                catch (AccessDeniedException exception)
                {
                    base.WriteError(exception, ErrorCategory.PermissionDenied, this.Identity);
                }
            }
            return(this.publicFolderStatisticsDataProvider);
        }
Ejemplo n.º 25
0
        internal void RefreshStoreCache()
        {
            this.AddVerboseLog("Start: RefreshStoreCache");
            bool flag = this.groupMailbox.WhenMailboxCreated == null || this.groupMailbox.WhenMailboxCreated.Value.AddMinutes(15.0).ToUniversalTime() > DateTime.UtcNow;

            if (flag)
            {
                return;
            }
            string text = null;

            try
            {
                ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
                DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(this.groupMailbox.Database.ObjectGuid);
                text = serverForDatabase.ServerFqdn;
                using (MapiMessageStoreSession mapiMessageStoreSession = new MapiMessageStoreSession(serverForDatabase.ServerLegacyDN, serverForDatabase.ServerLegacyDN + "/cn=Microsoft System Attendant", Fqdn.Parse(serverForDatabase.ServerFqdn)))
                {
                    MailboxId mailboxId = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(this.groupMailbox.Database), this.groupMailbox.ExchangeGuid);
                    this.AddVerboseLog(Strings.VerboseSaveStoreMailboxSecurityDescriptor(mailboxId.ToString(), mapiMessageStoreSession.ServerName));
                    mapiMessageStoreSession.Administration.PurgeCachedMailboxObject(mailboxId.MailboxGuid);
                }
            }
            catch (DatabaseNotFoundException)
            {
                this.AddVerboseLog(Strings.ErrorMailboxDatabaseNotFound(this.groupMailbox.Database.ToString()));
            }
            catch (MapiExceptionNetworkError)
            {
                this.AddVerboseLog(Strings.ErrorFailedToConnectToStore((text != null) ? text : string.Empty));
            }
            catch (MailboxNotFoundException)
            {
                this.AddVerboseLog(Strings.VerboseMailboxNotExistInStore(this.groupMailbox.DistinguishedName));
            }
            this.AddVerboseLog("End: RefreshStoreCache");
        }
Ejemplo n.º 26
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, DatabaseSchema.Name, this.Name);

            Database[] array = base.GlobalConfigSession.Find <Database>(null, QueryScope.SubTree, filter, null, 1);
            if (array != null && array.Length == 1)
            {
                DatabaseCopy[] databaseCopies = array[0].GetDatabaseCopies();
                if (databaseCopies != null && databaseCopies.Length > 0)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorDatabaseNotUnique(this.Name)), ErrorCategory.InvalidOperation, this.Name);
                }
                else
                {
                    Database database = array[0];
                    this.preExistingDatabase = (TDataObject)((object)base.DataSession.Read <TDataObject>(database.Id));
                }
            }
            else if (array != null && array.Length > 1)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorDatabaseNotUnique(this.Name)), ErrorCategory.InvalidOperation, this.Name);
            }
            this.ownerServer = (Server)base.GetDataObject <Server>(this.Server, base.GlobalConfigSession, this.RootId, new LocalizedString?(Strings.ErrorServerNotFound(this.Server.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(this.Server.ToString())));
            MapiTaskHelper.VerifyIsWithinConfigWriteScope(base.SessionSettings, this.ownerServer, new Task.ErrorLoggerDelegate(base.ThrowTerminatingError));
            if (!this.ownerServer.IsE14OrLater)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorModifyE12ServerNotAllowed), ErrorCategory.InvalidOperation, this.ownerServer.Identity);
            }
            if (!this.ownerServer.IsMailboxServer)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorOperationOnlyOnMailboxServer(this.ownerServer.Name)), ErrorCategory.InvalidOperation, this.ownerServer.Identity);
            }
            base.InternalValidate();
            TaskLogger.LogExit();
        }
 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();
 }
Ejemplo n.º 28
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();
        }
Ejemplo n.º 29
0
 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();
 }
Ejemplo n.º 30
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            if (this.OwnerServer == null)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(this.DataObject.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            base.VerifyIsWithinScopes((IConfigurationSession)base.DataSession, this.OwnerServer, true, new DataAccessTask <Database> .ADObjectOutOfScopeString(Strings.ErrorServerOutOfScope));
            if (this.DataObject != null)
            {
                MapiTaskHelper.VerifyDatabaseAndItsOwningServerInScope(base.SessionSettings, this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError));
            }
            ADObjectId adobjectId = new ADObjectId(this.OwnerServer.Guid);

            if (null == this.EdbFilePath && (base.Fields.IsModified("EdbFilePath") || base.Fields.IsChanged("EdbFilePath")))
            {
                base.WriteError(new ArgumentException(Strings.ErrorInvalidParameterValue("EdbFilePath", "null"), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity);
            }
            if (!this.IsEdbFilePathChanged && !this.isLogFolderPathChanged)
            {
                this.WriteWarning(Strings.FileLocationNotChanged);
                TaskLogger.LogExit();
                return;
            }
            this.needReportProgress = !base.ConfigurationOnly;
            this.shouldContinueToDoConfigurationOnly = true;
            try
            {
                QueryFilter            filter     = new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Guid, this.DataObject.Guid);
                ADObjectId             rootId     = this.DataObject.IsExchange2009OrLater ? this.DataObject.AdministrativeGroup.GetChildId("Databases") : this.DataObject.Server;
                IEnumerable <Database> collection = base.DataSession.FindPaged <Database>(filter, rootId, true, null, 0);
                List <Database>        databases  = new List <Database>(collection);
                if (this.IsEdbFilePathChanged)
                {
                    if (this.DataObject.IsExchange2009OrLater)
                    {
                        base.WriteVerbose(Strings.VerboseEdbFileLocationUniqueUnderDAGCondition(this.EdbFilePath.PathName));
                        ADObjectId[] serversId;
                        if (this.DataObject.Servers != null && this.DataObject.Servers.Length != 0)
                        {
                            serversId = this.DataObject.Servers;
                        }
                        else
                        {
                            serversId = new ADObjectId[]
                            {
                                this.DataObject.Server
                            };
                        }
                        if (!new EdbFileLocationUniqueUnderDAGCondition(this.EdbFilePath.PathName, adobjectId, serversId, databases).Verify())
                        {
                            base.WriteError(new ArgumentException(Strings.ErrorEdbFileLocationNotUniqueUnderSameDAG(this.EdbFilePath.PathName), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity);
                        }
                    }
                    else
                    {
                        base.WriteVerbose(Strings.VerboseEdbFileLocationUniqueUnderServerCondition(base.OwnerServerName, this.EdbFilePath.PathName));
                        if (!new EdbFileLocationUniqueUnderServerCondition(this.EdbFilePath.PathName, adobjectId, databases).Verify())
                        {
                            base.WriteError(new ArgumentException(Strings.ErrorEdbFileLocationNotUniqueUnderSameNode(this.EdbFilePath.PathName, base.OwnerServerName), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity);
                        }
                    }
                }
                if (this.isLogFolderPathChanged)
                {
                    if (this.DataObject.IsExchange2009OrLater)
                    {
                        ADObjectId[] serversId2;
                        if (this.DataObject.Servers != null && this.DataObject.Servers.Length != 0)
                        {
                            serversId2 = this.DataObject.Servers;
                        }
                        else
                        {
                            serversId2 = new ADObjectId[]
                            {
                                this.DataObject.Server
                            };
                        }
                        if (!new DbLogLocationUniqueUnderDAGCondition(this.LogFolderPath.PathName, adobjectId, serversId2, databases).Verify())
                        {
                            base.WriteError(new ArgumentException(Strings.ErrorLogFolderPathNotUniqueUnderSameDAG(this.LogFolderPath.PathName), "LogFolderPath"), ErrorCategory.InvalidArgument, this.DataObject.Identity);
                        }
                    }
                    else if (!new DbLogLocationUniqueUnderServerCondition(this.LogFolderPath.PathName, adobjectId, databases).Verify())
                    {
                        base.WriteError(new ArgumentException(Strings.ErrorLogFolderPathNotUniqueUnderTheSameNode(this.LogFolderPath.PathName, base.OwnerServerName), "LogFolderPath"), ErrorCategory.InvalidArgument, this.DataObject.Identity);
                    }
                }
                if (base.ConfigurationOnly)
                {
                    this.moveCatalogs = false;
                    if (!this.Force && !(this.shouldContinueToDoConfigurationOnly = base.ShouldContinue(Strings.WarningUseConfigurationOnly)))
                    {
                        TaskLogger.LogExit();
                        return;
                    }
                    if (this.IsEdbFilePathChanged)
                    {
                        base.WriteVerbose(Strings.VerboseCheckFileExistenceCondition(base.OwnerServerName, this.TargetEdbFilePath.PathName));
                        if (new FileNotExistCondition(this.OwnerServer.Fqdn, this.TargetEdbFilePath.PathName).Verify())
                        {
                            this.WriteWarning(Strings.WarningEdbFileLocationNotExists(this.EdbFilePath.PathName));
                        }
                    }
                    TaskLogger.LogExit();
                    return;
                }
                else
                {
                    if (this.needReportProgress)
                    {
                        base.WriteProgress(Strings.ProgressValidatingFileLocations, Strings.ProgressMoveDatabasePath(this.Identity.ToString()), 5);
                    }
                    if (this.IsEdbFilePathChanged)
                    {
                        if (this.OriginalEdbFilePath == null)
                        {
                            base.WriteError(new InvalidOperationException(Strings.ErrorOriginalEdbFilePathMissed(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.Identity);
                        }
                        if (this.IsDatabaseFilesCreated)
                        {
                            base.WriteVerbose(Strings.VerboseCheckFileExistenceCondition(base.OwnerServerName, this.OriginalEdbFilePath.PathName));
                            if (new FileNotExistCondition(this.OwnerServer.Fqdn, this.OriginalEdbFilePath.PathName).Verify())
                            {
                                base.WriteError(new InvalidOperationException(Strings.ErrorSourceFileNotFound(base.OwnerServerName, this.OriginalEdbFilePath.PathName)), ErrorCategory.InvalidOperation, this.Identity);
                            }
                        }
                        base.WriteVerbose(Strings.VerbosePathOnFixedOrNetworkDriveCondition(base.OwnerServerName, this.EdbFilePath.PathName));
                        if (!new PathOnFixedOrNetworkDriveCondition(this.OwnerServer.Fqdn, this.EdbFilePath.PathName).Verify())
                        {
                            base.WriteError(new ArgumentException(Strings.ErrorEdbFileLocationNotOnFixedDrive(this.EdbFilePath.PathName), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        base.WriteVerbose(Strings.VerboseCheckFileExistenceCondition(base.OwnerServerName, this.EdbFilePath.PathName));
                        if (!new FileNotExistCondition(this.OwnerServer.Fqdn, this.EdbFilePath.PathName).Verify())
                        {
                            base.WriteError(new ArgumentException(Strings.ErrorEdbFilePathOccupiedByFile(this.EdbFilePath.PathName, base.OwnerServerName), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        base.WriteVerbose(Strings.VerboseCheckDirectoryExistenceCondition(base.OwnerServerName, this.EdbFilePath.PathName));
                        if (!new DirectoryNotExistCondition(this.OwnerServer.Fqdn, this.EdbFilePath.PathName).Verify())
                        {
                            base.WriteError(new ArgumentException(Strings.ErrorEdbFilePathOccupiedByDirectory(this.EdbFilePath.PathName, base.OwnerServerName), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        string directoryName = Path.GetDirectoryName(this.EdbFilePath.PathName);
                        if (this.IsDatabaseFilesCreated && !SystemConfigurationTasksHelper.TryCreateDirectory(this.OwnerServer.Fqdn, directoryName, Database_Directory.GetDomainWidePermissions(), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning)))
                        {
                            base.WriteError(new ArgumentException(Strings.ErrorEdbFileDirectoryNotExist(directoryName, base.OwnerServerName), "EdbFilePath"), ErrorCategory.InvalidOperation, this.Identity);
                        }
                        if (this.moveCatalogs)
                        {
                            this.moveCatalogs = this.DataObject.ObjectClass.Contains("msExchPrivateMDB");
                            if (this.moveCatalogs)
                            {
                                string directoryName2 = Path.GetDirectoryName(this.OriginalEdbFilePath.PathName);
                                this.originalCatalogsPath = this.GenerateCatalogPath(directoryName2, this.DataObject.Guid);
                                base.WriteVerbose(Strings.VerboseCheckDirectoryExistenceCondition(base.OwnerServerName, this.originalCatalogsPath));
                                this.moveCatalogs = WmiWrapper.IsDirectoryExisting(this.OwnerServer.Fqdn, this.originalCatalogsPath);
                                if (this.moveCatalogs)
                                {
                                    string directoryName3 = Path.GetDirectoryName(this.EdbFilePath.PathName);
                                    this.targetCatalogsPath = this.GenerateCatalogPath(directoryName3, this.DataObject.Guid);
                                    this.moveCatalogs       = (this.originalCatalogsPath != this.targetCatalogsPath);
                                }
                            }
                        }
                    }
                    else
                    {
                        this.moveCatalogs = false;
                    }
                    if (base.ConfigurationOnly)
                    {
                        TaskLogger.LogExit();
                        return;
                    }
                    if (this.isLogFolderPathChanged)
                    {
                        if (this.OldLogFolderPath == null)
                        {
                            base.WriteError(new InvalidOperationException(Strings.ErrorOriginalLogFolderPathIsMissed(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                        }
                        base.WriteVerbose(Strings.VerbosePathOnFixedOrNetworkDriveCondition(this.OwnerServer.Fqdn, this.LogFolderPath.PathName));
                        if (!new PathOnFixedOrNetworkDriveCondition(this.OwnerServer.Fqdn, this.LogFolderPath.PathName).Verify())
                        {
                            base.WriteError(new ArgumentException(Strings.ErrorPathIsNotOnFixedDrive("LogFolderPath")), ErrorCategory.InvalidArgument, this.DataObject.Identity);
                        }
                        base.WriteVerbose(Strings.VerboseLogLocationAvailableCondition(this.OwnerServer.Fqdn, this.LogFolderPath.PathName));
                        if (!new LogLocationAvailableCondition(this.OwnerServer.Fqdn, this.LogFolderPath.PathName, this.DataObject.LogFilePrefix).Verify())
                        {
                            base.WriteError(new ArgumentException(Strings.ErrorLogFolderPathNotAvailable, "LogFolderPath"), ErrorCategory.InvalidArgument, this.DataObject.Identity);
                        }
                        base.WriteVerbose(Strings.VerboseCheckLogFileExistingInPath(this.OwnerServer.Fqdn, this.oldLogFolderPath.PathName));
                        if (!WmiWrapper.IsFileExistingInPath(this.OwnerServer.Fqdn, this.oldLogFolderPath.PathName, new WmiWrapper.FileFilter(this.LogFileFilter)))
                        {
                            base.WriteError(new InvalidOperationException(Strings.ErrorMoveDatabasePathAsSourceFileNotExist(this.oldLogFolderPath.PathName)), ErrorCategory.InvalidOperation, this.DataObject.Identity);
                        }
                    }
                }
            }
            catch (WmiException ex)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorFailedToConnectToServer(base.OwnerServerName, ex.Message)), ErrorCategory.InvalidOperation, this.Identity);
            }
            catch (UnauthorizedAccessException ex2)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorFailedToConnectToServer(base.OwnerServerName, ex2.Message)), ErrorCategory.InvalidOperation, this.Identity);
            }
            if (this.DataObject.ReplicationType == ReplicationType.Remote && !this.DataObject.Recovery)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorMoveDatabasePathInvalidOnReplicated), ErrorCategory.InvalidOperation, this.DataObject.Identity);
            }
            TaskLogger.LogExit();
        }