Example #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();
 }
Example #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();
        }