private bool CheckLocalServerRegistryRoles()
        {
            bool result;

            try
            {
                base.WriteVerbose(Strings.ReadingE14ServerRoles(this.m_serverName));
                this.m_serverRolesBitfield = MpServerRoles.GetLocalE12ServerRolesFromRegistry();
                if ((this.m_serverRolesBitfield & ServerRole.Mailbox) != ServerRole.Mailbox)
                {
                    this.WriteErrorAndMonitoringEvent(new NoMailboxRoleInstalledException(this.m_serverName), ErrorCategory.NotInstalled, null, 10002, "MSExchange Monitoring ReplicationHealth");
                    result = false;
                }
                else
                {
                    result = true;
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                CannotReadRolesFromRegistryException exception = new CannotReadRolesFromRegistryException(ex.Message);
                this.WriteErrorAndMonitoringEvent(exception, ErrorCategory.PermissionDenied, null, 10001, "MSExchange Monitoring ReplicationHealth");
                result = false;
            }
            catch (SecurityException ex2)
            {
                CannotReadRolesFromRegistryException exception2 = new CannotReadRolesFromRegistryException(ex2.Message);
                this.WriteErrorAndMonitoringEvent(exception2, ErrorCategory.PermissionDenied, null, 10001, "MSExchange Monitoring ReplicationHealth");
                result = false;
            }
            return(result);
        }
Пример #2
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     try
     {
         IEnumerable <TestServiceHealth.MonitoredService> source;
         if (Datacenter.IsMultiTenancyEnabled())
         {
             source = TestServiceHealth.DefaultMonitoredServicesList;
         }
         else
         {
             source = TestServiceHealth.DefaultMonitoredServicesList.Concat(new TestServiceHealth.MonitoredService[]
             {
                 new TestServiceHealth.MonitoredService("MSExchangeEdgeSync", false, true, ServerRole.HubTransport | ServerRole.Edge)
             });
         }
         source = from monitoredService in source
                  orderby monitoredService
                  select monitoredService;
         this.monitoredServicesArray = source.ToArray <TestServiceHealth.MonitoredService>();
         if (this.Server == null)
         {
             this.serverName = NativeHelpers.GetLocalComputerFqdn(false);
             try
             {
                 this.serverRolesBitfield = MpServerRoles.GetLocalE12ServerRolesFromRegistry();
                 goto IL_1AF;
             }
             catch (SecurityException ex)
             {
                 CannotReadRolesFromRegistryException exception = new CannotReadRolesFromRegistryException(ex.Message);
                 this.WriteErrorAndMonitoringEvent(exception, ErrorCategory.PermissionDenied, null, 10003, "MSExchange Monitoring ServiceHealth");
                 return;
             }
         }
         IConfigurationSession configurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(this.DomainController, true, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 708, "InternalValidate", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Monitoring\\Tasks\\TestServiceHealth.cs");
         configurationSession.ServerTimeout = new TimeSpan?(TimeSpan.FromSeconds((double)this.ActiveDirectoryTimeout));
         IEnumerable <Server> objects    = this.Server.GetObjects <Server>(null, configurationSession);
         IEnumerator <Server> enumerator = objects.GetEnumerator();
         Server server = null;
         if (enumerator.MoveNext())
         {
             server = enumerator.Current;
         }
         if (server == null || enumerator.MoveNext())
         {
             CannotLocateServerException exception2;
             if (server == null)
             {
                 exception2 = new CannotLocateServerException(Strings.ErrorServerNotFound(this.Server.ToString()));
             }
             else
             {
                 exception2 = new CannotLocateServerException(Strings.ErrorServerNotUnique(this.Server.ToString()));
             }
             this.WriteErrorAndMonitoringEvent(exception2, ErrorCategory.InvalidData, null, 10007, "MSExchange Monitoring ServiceHealth");
             return;
         }
         this.serverName          = server.Fqdn;
         this.serverRolesBitfield = server.CurrentServerRole;
         IL_1AF:
         this.serverRolesList = new List <ServerRole>(MpServerRoles.ValidE12MpRoles.Length);
         foreach (ServerRole serverRole in MpServerRoles.ValidE12MpRoles)
         {
             if ((serverRole & this.serverRolesBitfield) != ServerRole.None)
             {
                 this.serverRolesList.Add(serverRole);
             }
         }
         if (!base.HasErrors && this.serverRolesList.Count < 1)
         {
             NoExchangeRoleInstalledException exception3 = new NoExchangeRoleInstalledException(this.serverName);
             this.WriteErrorAndMonitoringEvent(exception3, ErrorCategory.InvalidArgument, null, 10007, "MSExchange Monitoring ServiceHealth");
         }
     }
     finally
     {
         if (base.HasErrors && this.MonitoringContext)
         {
             base.WriteObject(this.monitoringData);
         }
         TaskLogger.LogExit();
     }
 }