Ejemplo n.º 1
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            ADObjectId  descendantId = base.RootOrgContainerId.GetDescendantId(MonitoringOverride.RdnContainer);
            QueryFilter filter       = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, MonitoringOverride.ContainerName);

            Container[] array = this.ConfigurationSession.Find <Container>(descendantId, QueryScope.SubTree, filter, null, 0);
            if (array == null || array.Length == 0)
            {
                TaskLogger.LogExit();
                return;
            }
            foreach (object obj in Enum.GetValues(typeof(MonitoringItemTypeEnum)))
            {
                MonitoringItemTypeEnum monitoringItemTypeEnum = (MonitoringItemTypeEnum)obj;
                string               text           = monitoringItemTypeEnum.ToString();
                Container            childContainer = array[0].GetChildContainer(text);
                MonitoringOverride[] array2         = this.ConfigurationSession.Find <MonitoringOverride>(childContainer.Id, QueryScope.SubTree, null, null, 0);
                foreach (MonitoringOverride monitoringOverride in array2)
                {
                    this.WriteResult(new MonitoringOverrideObject(monitoringOverride, text));
                }
            }
            TaskLogger.LogExit();
        }
Ejemplo n.º 2
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         if (base.RegistryKeyHive != null)
         {
             foreach (object obj in Enum.GetValues(typeof(MonitoringItemTypeEnum)))
             {
                 MonitoringItemTypeEnum monitoringItemTypeEnum = (MonitoringItemTypeEnum)obj;
                 string text = monitoringItemTypeEnum.ToString();
                 using (RegistryKey registryKey = base.RegistryKeyHive.OpenSubKey(string.Format("{0}\\{1}", ServerMonitoringOverrideBase.OverridesBaseRegistryKey, text)))
                 {
                     if (registryKey != null)
                     {
                         string[] subKeyNames = registryKey.GetSubKeyNames();
                         foreach (string text2 in subKeyNames)
                         {
                             using (RegistryKey registryKey2 = registryKey.OpenSubKey(text2))
                             {
                                 string   propertyValue  = (string)registryKey2.GetValue("PropertyValue", string.Empty);
                                 string   expirationTime = (string)registryKey2.GetValue("ExpirationTime", string.Empty);
                                 string   applyVersion   = (string)registryKey2.GetValue("ApplyVersion", string.Empty);
                                 string   createdBy      = (string)registryKey2.GetValue("CreatedBy", string.Empty);
                                 string   createdTime    = (string)registryKey2.GetValue("TimeUpdated", string.Empty);
                                 string[] array2         = MonitoringOverrideHelpers.SplitMonitoringItemIdentity(text2, '~');
                                 base.WriteObject(new MonitoringOverrideObject((array2.Length >= 1) ? array2[0] : string.Empty, (array2.Length >= 2) ? array2[1] : string.Empty, (array2.Length >= 4) ? array2[3] : string.Empty, text, base.GetPropertyName(text2), propertyValue, expirationTime, applyVersion, createdBy, createdTime));
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (IOException ex)
     {
         base.WriteError(new FailedToRunServerMonitoringOverrideException(base.ServerName, ex.ToString()), ErrorCategory.ObjectNotFound, null);
     }
     catch (SecurityException ex2)
     {
         base.WriteError(new FailedToRunServerMonitoringOverrideException(base.ServerName, ex2.ToString()), ExchangeErrorCategory.Authorization, null);
     }
     catch (UnauthorizedAccessException ex3)
     {
         base.WriteError(new FailedToRunServerMonitoringOverrideException(base.ServerName, ex3.ToString()), ExchangeErrorCategory.Authorization, null);
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }
        internal bool ValidateMonitoringItemExist(string healthsetName, MonitoringItemTypeEnum itemType)
        {
            List <RpcGetMonitoringItemIdentity.RpcMonitorItemIdentity> monitoringItemsForHealthSet = this.GetMonitoringItemsForHealthSet(healthsetName);

            if (monitoringItemsForHealthSet != null)
            {
                foreach (RpcGetMonitoringItemIdentity.RpcMonitorItemIdentity rpcMonitorItemIdentity in monitoringItemsForHealthSet)
                {
                    if (string.Compare(itemType.ToString(), rpcMonitorItemIdentity.ItemType, true) == 0 && string.Compare(rpcMonitorItemIdentity.Name, this.helper.MonitoringItemName, true) == 0 && (string.IsNullOrWhiteSpace(this.helper.TargetResource) || string.Compare(rpcMonitorItemIdentity.TargetResource, this.helper.TargetResource, true) == 0))
                    {
                        return(true);
                    }
                }
                return(false);
            }
            return(false);
        }
 internal void ValidateGlobalLocalConflict(string identity, string[] registryKeys, string propertyName, MonitoringItemTypeEnum monitoringItemType)
 {
     if (registryKeys != null)
     {
         foreach (string text in registryKeys)
         {
             if (string.Compare(text, identity, true) == 0)
             {
                 base.WriteError(new PropertyAlreadyHasAnOverrideException(propertyName, this.helper.MonitoringItemIdentity, monitoringItemType.ToString()), ErrorCategory.ResourceExists, null);
             }
             else
             {
                 string[] array = MonitoringOverrideHelpers.SplitMonitoringItemIdentity(text, '~');
                 if (array.Length > 1 && string.Compare(array[0], this.helper.HealthSet, true) == 0 && string.Compare(array[1], this.helper.MonitoringItemName, true) == 0)
                 {
                     if (array.Length == 4 && !string.IsNullOrWhiteSpace(this.helper.TargetResource))
                     {
                         return;
                     }
                     if (array.Length == 4 && string.IsNullOrWhiteSpace(this.helper.TargetResource))
                     {
                         base.WriteError(new MonitoringItemAlreadyHasLocalOverrideException(this.helper.MonitoringItemIdentity, monitoringItemType.ToString(), this.GenerateMonitoringItemIdentityString(text)), ErrorCategory.ResourceExists, null);
                     }
                     else if (array.Length == 3 && !string.IsNullOrWhiteSpace(this.helper.TargetResource))
                     {
                         base.WriteError(new MonitoringItemAlreadyHasGlobalOverrideException(this.helper.MonitoringItemIdentity, monitoringItemType.ToString(), this.GenerateMonitoringItemIdentityString(text)), ErrorCategory.ResourceExists, null);
                     }
                 }
             }
         }
     }
 }