Beispiel #1
0
 protected override void WriteResult(IConfigurable dataObject)
 {
     TaskLogger.LogEnter(new object[]
     {
         dataObject.Identity,
         dataObject
     });
     if (this.Domain == null || (this.Domain != null && ((Server)dataObject).Domain.Equals(this.Domain, StringComparison.InvariantCultureIgnoreCase)))
     {
         ExchangeServer exchangeServer = new ExchangeServer((Server)dataObject);
         if (this.Status && exchangeServer.IsProvisionedServer)
         {
             this.WriteWarning(Strings.StatusSpecifiedForProvisionedServer);
         }
         if (this.Status && !exchangeServer.IsReadOnly && !((Server)dataObject).IsProvisionedServer)
         {
             if (string.IsNullOrEmpty(exchangeServer.Fqdn))
             {
                 this.WriteWarning(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, exchangeServer.Identity.ToString(), ServerSchema.Fqdn.Name));
             }
             else
             {
                 Exception ex = null;
                 string[]  array;
                 string[]  array2;
                 string    staticConfigDomainController;
                 string[]  array3;
                 bool?     errorReportingEnabled;
                 GetExchangeServer.GetConfigurationFromRegistry(exchangeServer.Fqdn, out array, out array2, out staticConfigDomainController, out array3, out errorReportingEnabled, out ex);
                 if (ex != null)
                 {
                     this.WriteWarning(Strings.ErrorAccessingRegistryRaisesException(exchangeServer.Fqdn, ex.Message));
                 }
                 exchangeServer.StaticDomainControllers         = array;
                 exchangeServer.StaticGlobalCatalogs            = array2;
                 exchangeServer.StaticConfigDomainController    = staticConfigDomainController;
                 exchangeServer.StaticExcludedDomainControllers = array3;
                 exchangeServer.ErrorReportingEnabled           = errorReportingEnabled;
                 if (exchangeServer.IsExchange2007OrLater)
                 {
                     try
                     {
                         exchangeServer.RefreshDsAccessData();
                     }
                     catch (ADTransientException ex2)
                     {
                         this.WriteWarning(Strings.ErrorADTopologyServiceNotAvailable(exchangeServer.Fqdn, ex2.Message));
                     }
                 }
                 exchangeServer.ResetChangeTracking();
             }
         }
         base.WriteResult(exchangeServer);
     }
     TaskLogger.LogExit();
 }
Beispiel #2
0
        protected override void StampChangesOn(IConfigurable dataObject)
        {
            TaskLogger.LogEnter();
            base.StampChangesOn(dataObject);
            Server         server   = (Server)dataObject;
            ExchangeServer instance = this.Instance;

            if (!((Server)dataObject).IsProvisionedServer)
            {
                if (string.IsNullOrEmpty(server.Fqdn))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, server.Identity.ToString(), ServerSchema.Fqdn.Name)), ErrorCategory.ReadError, server.Identity);
                }
                if (instance.IsModified(ExchangeServerSchema.StaticDomainControllers) || instance.IsModified(ExchangeServerSchema.StaticGlobalCatalogs) || instance.IsModified(ExchangeServerSchema.StaticConfigDomainController) || instance.IsModified(ExchangeServerSchema.StaticExcludedDomainControllers) || instance.IsModified(ExchangeServerSchema.ErrorReportingEnabled) || base.Fields.IsModified(ServerSchema.ErrorReportingEnabled))
                {
                    Exception ex = null;
                    GetExchangeServer.GetConfigurationFromRegistry(server.Fqdn, out this.oldDomainControllers, out this.oldGlobalCatalogs, out this.oldConfigDomainController, out this.oldExcludedDomainControllers, out this.oldErrorReporting, out ex);
                    if (ex != null)
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorAccessingRegistryRaisesException(server.Fqdn, ex.Message)), ErrorCategory.ReadError, server.Identity);
                    }
                }
                else
                {
                    this.oldDomainControllers         = new string[0];
                    this.oldGlobalCatalogs            = new string[0];
                    this.oldConfigDomainController    = string.Empty;
                    this.oldExcludedDomainControllers = new string[0];
                    this.oldErrorReporting            = null;
                }
            }
            else if (instance.IsModified(ExchangeServerSchema.StaticDomainControllers) || instance.IsModified(ExchangeServerSchema.StaticGlobalCatalogs) || instance.IsModified(ExchangeServerSchema.StaticConfigDomainController) || instance.IsModified(ExchangeServerSchema.StaticExcludedDomainControllers) || instance.IsModified(ExchangeServerSchema.ErrorReportingEnabled) || base.Fields.IsModified(ServerSchema.ErrorReportingEnabled))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorInvalidOperationOnProvisionedServer), ErrorCategory.InvalidArgument, server.Identity);
            }
            if (!instance.IsModified(ExchangeServerSchema.StaticDomainControllers))
            {
                this.isDCChanged = false;
                server.StaticDomainControllers = this.oldDomainControllers;
            }
            else
            {
                server.StaticDomainControllers = instance.StaticDomainControllers;
            }
            if (!instance.IsModified(ExchangeServerSchema.StaticGlobalCatalogs))
            {
                this.isGCChanged            = false;
                server.StaticGlobalCatalogs = this.oldGlobalCatalogs;
            }
            else
            {
                server.StaticGlobalCatalogs = instance.StaticGlobalCatalogs;
            }
            if (!instance.IsModified(ExchangeServerSchema.StaticExcludedDomainControllers))
            {
                this.isExcludedDCChanged = false;
                server.StaticExcludedDomainControllers = this.oldExcludedDomainControllers;
            }
            else
            {
                server.StaticExcludedDomainControllers = instance.StaticExcludedDomainControllers;
            }
            TaskLogger.LogExit();
        }
Beispiel #3
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            bool flag  = false;
            bool flag2 = false;
            InformationStoreSkuLimits informationStoreSkuLimits = null;
            IConfigurationSession     configurationSession      = (IConfigurationSession)base.DataSession;
            ExchangeServer            exchangeServer            = new ExchangeServer(this.DataObject);

            if (this.isErrorReportingChanged && this.oldErrorReporting != null && !this.oldErrorReporting.Value && (this.DataObject.ErrorReportingEnabled == null || this.DataObject.ErrorReportingEnabled.Value) && !base.ShouldContinue(Strings.ErrorReportingEnabledLegalMessage))
            {
                return;
            }
            if (this.ShouldGeneratePid())
            {
                this.DataObject.ProductID = this.ProductKey.GenerateProductID();
                this.DataObject.Edition   = this.ProductKey.Sku.ServerEdition;
                ADObjectId       childId          = this.DataObject.Id.GetChildId("InformationStore");
                InformationStore informationStore = configurationSession.Read <InformationStore>(childId);
                if (informationStore != null)
                {
                    informationStoreSkuLimits        = new InformationStoreSkuLimits(informationStore);
                    informationStore.MinAdminVersion = new int?(ExchangeObjectVersion.Exchange2007.ExchangeBuild.ToExchange2003FormatInt32());
                    informationStore.SetExchangeVersion(ExchangeObjectVersion.Exchange2007);
                    this.ProductKey.Sku.InformationStoreSkuLimits.UpdateInformationStore(informationStore);
                    configurationSession.Save(informationStore);
                    flag = true;
                }
            }
            if ((this.isDCChanged || this.isGCChanged || this.isCDCChanged || this.isExcludedDCChanged || this.isErrorReportingChanged) && !this.DataObject.IsProvisionedServer)
            {
                Exception ex = null;
                GetExchangeServer.SetConfigurationToRegistry(exchangeServer.Fqdn, exchangeServer.StaticDomainControllers, exchangeServer.StaticGlobalCatalogs, exchangeServer.StaticConfigDomainController ?? string.Empty, exchangeServer.StaticExcludedDomainControllers, exchangeServer.ErrorReportingEnabled, out ex);
                if (ex != null)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorFaildToWriteRegistry(exchangeServer.Fqdn, ex.Message)), ErrorCategory.WriteError, this.Identity);
                }
                flag2 = true;
            }
            bool flag3 = false;

            try
            {
                if (this.DataObject.IsModified(ServerSchema.MonitoringGroup))
                {
                    bool useConfigNC      = configurationSession.UseConfigNC;
                    bool useGlobalCatalog = configurationSession.UseGlobalCatalog;
                    try
                    {
                        configurationSession.UseConfigNC      = false;
                        configurationSession.UseGlobalCatalog = true;
                        ADComputer adcomputer = ((ITopologyConfigurationSession)configurationSession).FindComputerByHostName(this.DataObject.Name);
                        if (adcomputer == null)
                        {
                            base.WriteError(new DirectoryObjectNotFoundException(this.DataObject.Id.ToString()), ErrorCategory.WriteError, this.Identity);
                        }
                        adcomputer.MonitoringGroup = this.DataObject.MonitoringGroup;
                        configurationSession.Save(adcomputer);
                    }
                    finally
                    {
                        configurationSession.UseConfigNC      = useConfigNC;
                        configurationSession.UseGlobalCatalog = useGlobalCatalog;
                    }
                }
                base.InternalProcessRecord();
                flag3 = true;
                if (flag)
                {
                    this.WriteWarning(Strings.ProductKeyRestartWarning);
                }
            }
            finally
            {
                if (!flag3)
                {
                    if (flag2)
                    {
                        Exception ex2 = null;
                        GetExchangeServer.SetConfigurationToRegistry(exchangeServer.Fqdn, this.oldDomainControllers, this.oldGlobalCatalogs, this.oldConfigDomainController ?? string.Empty, this.oldExcludedDomainControllers, new bool?(this.oldErrorReporting != null && this.oldErrorReporting.Value), out ex2);
                        if (ex2 != null)
                        {
                            this.WriteError(new InvalidOperationException(Strings.ErrorFaildToWriteRegistry(this.DataObject.Name, ex2.Message)), ErrorCategory.WriteError, this.Identity, false);
                        }
                    }
                    if (flag)
                    {
                        ADObjectId       childId2          = this.DataObject.Id.GetChildId("InformationStore");
                        InformationStore informationStore2 = configurationSession.Read <InformationStore>(childId2);
                        informationStoreSkuLimits.UpdateInformationStore(informationStore2);
                        configurationSession.Save(informationStore2);
                    }
                }
            }
            TaskLogger.LogExit();
        }