Пример #1
0
        private Server GetServer(ServerIdParameter server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            IEnumerable <Server> objects = server.GetObjects <Server>(null, base.GlobalConfigSession);

            using (IEnumerator <Server> enumerator = objects.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    return(enumerator.Current);
                }
            }
            throw new ServerNotFoundException("server not found", server.ToString());
        }
Пример #2
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            base.InternalProcessRecord();
            ServerIdParameter serverIdParameter = new ServerIdParameter();
            Server            server            = (Server)base.GetDataObject <Server>(serverIdParameter, base.DataSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));

            if (!server.IsClientAccessServer && !server.IsCafeServer)
            {
                base.ThrowTerminatingError(server.GetServerRoleError(ServerRole.ClientAccess), ErrorCategory.InvalidOperation, server);
            }
            using (ServerManager serverManager = new ServerManager())
            {
                ApplicationPool applicationPool = serverManager.ApplicationPools["MSExchangeOWAAppPool"];
                if (applicationPool == null)
                {
                    base.ThrowTerminatingError(new ADNoSuchObjectException(Strings.ErrorOWAVdirAppPoolNotExist), ErrorCategory.ObjectNotFound, serverManager.ApplicationPools);
                }
                applicationPool.ManagedPipelineMode = 0;
                serverManager.CommitChanges();
            }
            QueryFilter filter = new ComparisonFilter(ComparisonOperator.NotEqual, ADOwaVirtualDirectorySchema.OwaVersion, OwaVersions.Exchange2003or2000);

            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(ADOwaVirtualDirectory), filter, server.Identity, true));
            IConfigDataProvider dataSession = base.DataSession;
            IEnumerable <ADOwaVirtualDirectory> enumerable = dataSession.FindPaged <ADOwaVirtualDirectory>(filter, server.Identity, true, null, 0);

            foreach (ADOwaVirtualDirectory adowaVirtualDirectory in enumerable)
            {
                if (adowaVirtualDirectory.WebSite.Equals("Exchange Back End", StringComparison.OrdinalIgnoreCase))
                {
                    string metabasePath = adowaVirtualDirectory.MetabasePath;
                    try
                    {
                        base.WriteVerbose(Strings.VerboseConnectingIISVDir(metabasePath));
                        using (IisUtility.CreateIISDirectoryEntry(metabasePath))
                        {
                            if (!DirectoryEntry.Exists(metabasePath))
                            {
                                this.WriteWarning(Strings.OwaAdOrphanFound(adowaVirtualDirectory.Identity.ToString()));
                                continue;
                            }
                            if (!IisUtility.WebDirObjectExists(metabasePath, this.owaVersion))
                            {
                                base.WriteVerbose(Strings.VerboseCreatingChildVDir(this.owaVersion, metabasePath));
                                CreateVirtualDirectory createVirtualDirectory = new CreateVirtualDirectory();
                                createVirtualDirectory.Name   = this.owaVersion;
                                createVirtualDirectory.Parent = metabasePath;
                                createVirtualDirectory.CustomizedVDirProperties = OwaVirtualDirectoryHelper.GetVersionVDirProperties();
                                createVirtualDirectory.LocalPath = (string)IisUtility.GetIisPropertyValue("Path", createVirtualDirectory.CustomizedVDirProperties);
                                createVirtualDirectory.Initialize();
                                createVirtualDirectory.Execute();
                            }
                        }
                        OwaVirtualDirectoryHelper.CreateLegacyVDirs(metabasePath, true);
                        OwaVirtualDirectoryHelper.CreateOwaCalendarVDir(metabasePath, VirtualDirectoryRole.Mailbox);
                        if (ExchangeServiceVDirHelper.IsBackEndVirtualDirectory(adowaVirtualDirectory))
                        {
                            WebAppVirtualDirectoryHelper.UpdateMetabase(adowaVirtualDirectory, metabasePath, true);
                        }
                    }
                    catch (COMException ex)
                    {
                        base.WriteError(new IISGeneralCOMException(ex.Message, ex.ErrorCode, ex), ErrorCategory.InvalidOperation, null);
                    }
                    if (adowaVirtualDirectory.ExchangeVersion.IsOlderThan(adowaVirtualDirectory.MaximumSupportedExchangeObjectVersion))
                    {
                        try
                        {
                            adowaVirtualDirectory.SetExchangeVersion(adowaVirtualDirectory.MaximumSupportedExchangeObjectVersion);
                            base.DataSession.Save(adowaVirtualDirectory);
                        }
                        catch (DataSourceTransientException exception)
                        {
                            base.WriteError(exception, ErrorCategory.WriteError, null);
                        }
                    }
                }
            }
            TaskLogger.LogExit();
        }
Пример #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));
        }
Пример #4
0
        protected Server LookupServer(ServerIdParameter serverParam)
        {
            ADObjectId id     = new ServersContainer().Id;
            Server     server = (Server)base.GetDataObject <Server>(serverParam, base.GlobalConfigSession, id, new LocalizedString?(Strings.ErrorMailboxServerNotFound(serverParam.ToString())), new LocalizedString?(Strings.ErrorMailboxServerNotUnique(serverParam.ToString())));

            if (!server.IsMailboxServer)
            {
                base.WriteError(server.GetServerRoleError(ServerRole.Mailbox), ErrorCategory.InvalidOperation, serverParam);
                return(null);
            }
            if (!server.IsE14OrLater)
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorServerNotE14OrLater(server.Name)), ErrorCategory.InvalidOperation, serverParam);
                return(null);
            }
            return(server);
        }
        private Server GetServerFromId(ServerIdParameter serverId)
        {
            Server             server = (Server)base.Task.GetAdDataObject <Server>(serverId, base.Task.ConfigurationSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverId.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverId.ToString())));
            LocalizedException ex     = null;

            if (!server.IsExchange2007OrLater)
            {
                ex = new OperationOnOldServerException(server.Name);
            }
            else if (!server.IsMailboxServer)
            {
                ex = new OperationOnlyOnMailboxServerException(server.Name);
            }
            if (ex != null)
            {
                base.WriteErrorAndMonitoringEvent(ex, ErrorCategory.InvalidArgument, 1006);
            }
            return(server);
        }
Пример #6
0
        protected override void InternalValidate()
        {
            base.InternalValidate();
            if (base.HasErrors)
            {
                return;
            }
            if (this.Identity != null)
            {
                this.Server = ServerIdParameter.Parse(this.Identity.Server);
            }
            if (this.Server == null || string.Compare(this.Server.ToString(), "localhost", true) == 0)
            {
                this.Server = new ServerIdParameter();
            }
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(base.CurrentOrganizationId), 263, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\transport\\Queueviewer\\QueueTasks.cs");
            ServerIdParameter     server = this.Server;
            Server           entry       = (Server)this.GetDataObject <Server>(server, tenantOrTopologyConfigurationSession, null, null, Strings.ErrorServerNotFound(server.ToString()), Strings.ErrorServerNotUnique(server.ToString()));
            ADScopeException ex;

            if (!tenantOrTopologyConfigurationSession.TryVerifyIsWithinScopes(entry, true, out ex))
            {
                base.WriteError(new TaskInvalidOperationException(Strings.ErrorCannotChangeObjectOutOfWriteScope((this.Identity != null) ? this.Identity.ToString() : this.Server.ToString(), (ex == null) ? string.Empty : ex.Message), ex), ExchangeErrorCategory.Context, this.Identity);
            }
            if (this.Filter != null && !VersionedQueueViewerClient.UsePropertyBagBasedAPI((string)this.Server))
            {
                this.InitializeInnerFilter <QueueInfoSchema>(this.Filter, ObjectSchema.GetInstance <QueueInfoSchema>());
            }
        }
Пример #7
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);
            }
        }
Пример #8
0
 internal static Server GetServerObject(ServerIdParameter serverIdParameter, IConfigurationSession dataSession, ObjectId rootId, DataAccessHelper.GetDataObjectDelegate getDataObjectServer)
 {
     return((Server)getDataObjectServer(serverIdParameter, dataSession, rootId, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString()))));
 }
Пример #9
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            Server server = (Server)base.PrepareDataObject();

            if (!base.Fields.IsModified("SubmissionServerOverrideList") && server.IsModified(MailboxServerSchema.SubmissionServerOverrideLIst))
            {
                foreach (ADObjectId adObjectId in server.SubmissionServerOverrideList.Added)
                {
                    ServerIdParameter serverIdParameter = new ServerIdParameter(adObjectId);
                    Server            server2           = (Server)base.GetDataObject <Server>(serverIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));
                }
            }
            TaskLogger.LogExit();
            return(server);
        }
Пример #10
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            ServerIdParameter serverIdParameter = new ServerIdParameter();

            this.Server = (Server)base.GetDataObject <Server>(serverIdParameter, base.DataSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));
            if (!this.ShouldUpdateVirtualDirectory())
            {
                base.WriteError(this.Server.GetServerRoleError(ServerRole.Mailbox | ServerRole.ClientAccess | ServerRole.UnifiedMessaging | ServerRole.HubTransport), ErrorCategory.InvalidOperation, this.Server);
            }
            base.InternalValidate();
            TaskLogger.LogExit();
        }
Пример #11
0
        protected void ResolveDatabaseAndServer()
        {
            DatabaseIdParameter databaseIdParameter   = this.Database;
            ServerIdParameter   serverIdParameter     = this.Server ?? new ServerIdParameter();
            ActiveManager       activeManagerInstance = ActiveManager.GetActiveManagerInstance();

            if (this.Identity != null)
            {
                bool flag = false;
                if (this.isRunningLogonStatisticsTask)
                {
                    TIdentity tidentity            = this.Identity;
                    IEnumerable <Database> objects = tidentity.GetObjects <Database>(null, base.GlobalConfigSession);
                    foreach (Database item in objects)
                    {
                        this.databases.Add(item);
                    }
                    if (this.databases.Count > 0)
                    {
                        if (this.databases[0].Server == null)
                        {
                            string    name       = typeof(Database).Name;
                            TIdentity tidentity2 = this.Identity;
                            base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name, tidentity2.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(this.databases[0].Guid);
                        serverIdParameter = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);
                        if (string.IsNullOrEmpty(this.databases[0].ExchangeLegacyDN))
                        {
                            string    name2      = typeof(Database).Name;
                            TIdentity tidentity3 = this.Identity;
                            base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name2, tidentity3.ToString(), DatabaseSchema.ExchangeLegacyDN.Name)), ErrorCategory.InvalidArgument, this.Identity);
                        }
                        this.identity = new MailboxId(this.databases[0].ExchangeLegacyDN);
                        flag          = true;
                    }
                }
                if (!flag)
                {
                    IIdentityParameter  id            = this.Identity;
                    IConfigDataProvider session       = this.readOnlyRecipientSession;
                    ObjectId            rootID        = null;
                    TIdentity           tidentity4    = this.Identity;
                    LocalizedString?    notFoundError = new LocalizedString?(Strings.ErrorMailboxNotFound(tidentity4.ToString()));
                    TIdentity           tidentity5    = this.Identity;
                    ADRecipient         adrecipient   = (ADRecipient)base.GetDataObject <ADRecipient>(id, session, rootID, notFoundError, new LocalizedString?(Strings.ErrorMailboxNotUnique(tidentity5.ToString())));
                    Guid       guid = Guid.Empty;
                    string     mailboxExchangeLegacyDn = null;
                    ADObjectId adobjectId = null;
                    if (string.IsNullOrEmpty(adrecipient.LegacyExchangeDN))
                    {
                        string    name3      = typeof(ADRecipient).Name;
                        TIdentity tidentity6 = this.Identity;
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name3, tidentity6.ToString(), ADRecipientSchema.LegacyExchangeDN.Name)), ErrorCategory.InvalidArgument, this.Identity);
                    }
                    ADUser                   aduser                   = adrecipient as ADUser;
                    ADSystemMailbox          adsystemMailbox          = adrecipient as ADSystemMailbox;
                    ADSystemAttendantMailbox adsystemAttendantMailbox = adrecipient as ADSystemAttendantMailbox;
                    ADPublicDatabase         adpublicDatabase         = adrecipient as ADPublicDatabase;
                    if (aduser != null)
                    {
                        if (this.isRunningMailboxStatisticsTask && aduser.RecipientTypeDetails == RecipientTypeDetails.AuditLogMailbox && !this.GetAuditLogMailboxStatistics())
                        {
                            TIdentity tidentity7 = this.Identity;
                            base.WriteError(new MdbAdminTaskException(Strings.RecipientNotFoundException(tidentity7.ToString())), ErrorCategory.InvalidArgument, null);
                        }
                        bool archiveMailboxStatistics = this.GetArchiveMailboxStatistics();
                        if (aduser.RecipientType == RecipientType.MailUser && !archiveMailboxStatistics)
                        {
                            base.WriteError(new MdbAdminTaskException(Strings.RecipientTypeNotValid(aduser.ToString())), (ErrorCategory)1003, this.Identity);
                        }
                        RecipientIdParameter recipientIdParameter = this.Identity as RecipientIdParameter;
                        if (this.isRunningMailboxStatisticsTask && recipientIdParameter != null && recipientIdParameter.RawMailboxGuidInvolvedInSearch != Guid.Empty && aduser.MailboxLocations != null)
                        {
                            IMailboxLocationInfo mailboxLocation = aduser.MailboxLocations.GetMailboxLocation(recipientIdParameter.RawMailboxGuidInvolvedInSearch);
                            if (mailboxLocation != null)
                            {
                                guid       = mailboxLocation.MailboxGuid;
                                adobjectId = mailboxLocation.DatabaseLocation;
                            }
                        }
                        if (guid == Guid.Empty || adobjectId == null)
                        {
                            if (archiveMailboxStatistics)
                            {
                                if (aduser.ArchiveGuid != Guid.Empty)
                                {
                                    if (aduser.ArchiveDomain != null)
                                    {
                                        base.WriteError(new MdbAdminTaskException(Strings.ErrorRemoteArchiveNoStats(aduser.ToString())), (ErrorCategory)1003, this.Identity);
                                    }
                                    else
                                    {
                                        guid       = aduser.ArchiveGuid;
                                        adobjectId = (aduser.ArchiveDatabase ?? aduser.Database);
                                    }
                                }
                                else
                                {
                                    base.WriteError(new MdbAdminTaskException(Strings.ErrorArchiveNotEnabled(aduser.ToString())), ErrorCategory.InvalidArgument, this.Identity);
                                }
                            }
                            else
                            {
                                guid       = aduser.ExchangeGuid;
                                adobjectId = aduser.Database;
                            }
                        }
                        mailboxExchangeLegacyDn = aduser.LegacyExchangeDN;
                    }
                    else if (adsystemMailbox != null)
                    {
                        guid = adsystemMailbox.ExchangeGuid;
                        mailboxExchangeLegacyDn = adsystemMailbox.LegacyExchangeDN;
                        adobjectId = adsystemMailbox.Database;
                    }
                    else if (adsystemAttendantMailbox != null)
                    {
                        guid = adsystemAttendantMailbox.Guid;
                        mailboxExchangeLegacyDn = adsystemAttendantMailbox.LegacyExchangeDN;
                        adobjectId = adsystemAttendantMailbox.Database;
                    }
                    else if (adpublicDatabase != null)
                    {
                        mailboxExchangeLegacyDn = adpublicDatabase.LegacyExchangeDN;
                        adobjectId = (ADObjectId)adpublicDatabase.Identity;
                    }
                    if (adobjectId == null)
                    {
                        string    name4      = adrecipient.GetType().Name;
                        TIdentity tidentity8 = this.Identity;
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(name4, tidentity8.ToString(), IADMailStorageSchema.Database.Name)), ErrorCategory.InvalidArgument, adrecipient);
                    }
                    databaseIdParameter = new DatabaseIdParameter(adobjectId);
                    if (this.isRunningLogonStatisticsTask)
                    {
                        this.identity = new MailboxId(mailboxExchangeLegacyDn);
                    }
                    else
                    {
                        this.identity = new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), guid);
                    }
                }
            }
            if (databaseIdParameter != null)
            {
                databaseIdParameter.AllowLegacy = true;
                LocalizedString empty  = LocalizedString.Empty;
                LocalizedString empty2 = LocalizedString.Empty;
                Database        database;
                if (this.isRunningLogonStatisticsTask)
                {
                    database = (Database)base.GetDataObject <Database>(databaseIdParameter, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(databaseIdParameter.ToString())));
                }
                else
                {
                    database = (MailboxDatabase)base.GetDataObject <MailboxDatabase>(databaseIdParameter, base.GlobalConfigSession, null, new LocalizedString?(Strings.ErrorMailboxDatabaseNotFound(databaseIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxDatabaseNotUnique(databaseIdParameter.ToString())));
                }
                if (database.Server == null)
                {
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(this.isRunningLogonStatisticsTask ? typeof(Database).Name : typeof(MailboxDatabase).Name, databaseIdParameter.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, database);
                }
                this.databases = new List <Database>(new Database[]
                {
                    database
                });
                if (this.CopyOnServer != null)
                {
                    serverIdParameter = this.CopyOnServer;
                }
                else
                {
                    DatabaseLocationInfo serverForDatabase = activeManagerInstance.GetServerForDatabase(database.Guid);
                    serverIdParameter = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);
                }
            }
            if (this.Server != null)
            {
                serverIdParameter = this.Server;
                this.server       = MapiTaskHelper.GetMailboxServer(this.Server, base.GlobalConfigSession, new Task.ErrorLoggerDelegate(base.WriteError));
            }
            else
            {
                this.server = (Server)base.GetDataObject <Server>(serverIdParameter, base.GlobalConfigSession, null, new LocalizedString?((this.Identity == null && this.Database == null) ? Strings.ErrorLocalMachineIsNotExchangeServer : Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));
                if (!this.server.IsExchange2007OrLater || !this.server.IsMailboxServer)
                {
                    if (this.Identity != null)
                    {
                        TIdentity tidentity9 = this.Identity;
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorMailboxInNonMailboxServer(tidentity9.ToString())), ErrorCategory.InvalidArgument, this.server);
                    }
                    if (this.Database != null)
                    {
                        base.WriteError(new MdbAdminTaskException(Strings.ErrorDatabaseInNonMailboxServer(this.Database.ToString())), ErrorCategory.InvalidArgument, this.server);
                    }
                    base.WriteError(new MdbAdminTaskException(Strings.ErrorLocalServerIsNotMailboxServer), ErrorCategory.InvalidArgument, this.server);
                }
            }
            if (string.IsNullOrEmpty(this.server.ExchangeLegacyDN))
            {
                base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, serverIdParameter.ToString(), ServerSchema.ExchangeLegacyDN.Name)), ErrorCategory.InvalidArgument, this.Identity);
            }
            if (this.databases.Count == 0)
            {
                if (this.isRunningLogonStatisticsTask)
                {
                    this.FilterActiveDatabases(activeManagerInstance, this.server.GetDatabases());
                    return;
                }
                this.FilterActiveDatabases(activeManagerInstance, this.server.GetMailboxDatabases());
            }
        }
Пример #12
0
        private void ResolveDatabaseAndServer()
        {
            DatabaseIdParameter database = this.Database;

            database.AllowLegacy = false;
            Database database2 = (Database)base.GetDataObject <Database>(database, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorDatabaseNotFound(database.ToString())), new LocalizedString?(Strings.ErrorDatabaseNotUnique(database.ToString())));

            if (database2.Server == null)
            {
                base.WriteError(new MdbAdminTaskException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Database).Name, database.ToString(), DatabaseSchema.Server.Name)), ErrorCategory.InvalidArgument, database2);
            }
            ActiveManager        activeManagerInstance = ActiveManager.GetActiveManagerInstance();
            DatabaseLocationInfo serverForDatabase     = activeManagerInstance.GetServerForDatabase(database2.Guid);
            ServerIdParameter    serverIdParameter     = ServerIdParameter.Parse(serverForDatabase.ServerFqdn);

            this.targetServer = (Server)base.GetDataObject <Server>(serverIdParameter, this.ConfigurationSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString())));
            if (!this.TargetServer.IsE14OrLater || !this.TargetServer.IsMailboxServer)
            {
                base.WriteError(new MdbAdminTaskException(Strings.ErrorLocalServerIsNotMailboxServer), ErrorCategory.InvalidArgument, this.TargetServer);
            }
            this.targetDatabase = database2;
        }