/// <summary> /// Overrides the <paramref name="configurationObject"/>'s properties with the Group Policy values from the /// registry. /// </summary> /// <param name="configurationObject">The configuration object for instances that must be managed.</param> /// <param name="policyKey">The <see cref="IRegistryKey"/> which holds the Group Policy overrides for the /// configuration element.</param> /// <remarks>Subclasses implementing this method must retrieve all the override values from the registry /// before making modifications to the <paramref name="configurationObject"/> so any error retrieving /// the override values will cancel policy processing.</remarks> protected override void OverrideWithGroupPolicies(MsmqTraceListenerData configurationObject, IRegistryKey policyKey) { String formatterOverride = GetFormatterPolicyOverride(policyKey); MessagePriority?messagePriorityOverride = policyKey.GetEnumValue <MessagePriority>(MessagePriorityPropertyName); String queuePathOverride = policyKey.GetStringValue(QueuePathPropertyName); bool? recoverableOverride = policyKey.GetBoolValue(RecoverablePropertyName); TimeSpan timeToBeReceivedOverride = GetTimeSpanOverride(policyKey, TimeToBeReceivedPropertyName); TimeSpan timeToReachQueueOverride = GetTimeSpanOverride(policyKey, TimeToReachQueuePropertyName); TraceOptions? traceOutputOptionsOverride = GetFlagsEnumOverride <TraceOptions>(policyKey, TraceOutputOptionsPropertyName); SourceLevels?filterOverride = policyKey.GetEnumValue <SourceLevels>(FilterPropertyName); MessageQueueTransactionType?transactionTypeOverride = policyKey.GetEnumValue <MessageQueueTransactionType>(TransactionTypePropertyName); bool?usedAuthenticationOverride = policyKey.GetBoolValue(UseAuthenticationPropertyName); bool?useDeadLetterOverride = policyKey.GetBoolValue(UseDeadLetterQueuePropertyName); bool?useEncryptionOverride = policyKey.GetBoolValue(UseEncryptionPropertyName); configurationObject.Formatter = formatterOverride; configurationObject.MessagePriority = messagePriorityOverride.Value; configurationObject.QueuePath = queuePathOverride; configurationObject.Recoverable = recoverableOverride.Value; configurationObject.TimeToReachQueue = timeToReachQueueOverride; configurationObject.TimeToBeReceived = timeToBeReceivedOverride; configurationObject.TraceOutputOptions = traceOutputOptionsOverride.Value; configurationObject.Filter = filterOverride.Value; configurationObject.TransactionType = transactionTypeOverride.Value; configurationObject.UseAuthentication = usedAuthenticationOverride.Value; configurationObject.UseDeadLetterQueue = useDeadLetterOverride.Value; configurationObject.UseEncryption = useEncryptionOverride.Value; }
/// <summary> /// Overrides the <paramref name="configurationSection"/>'s properties with the Group Policy values from /// the registry. /// </summary> /// <param name="configurationSection">The configuration section that must be managed.</param> /// <param name="policyKey">The <see cref="IRegistryKey"/> which holds the Group Policy overrides.</param> protected override void OverrideWithGroupPoliciesForConfigurationSection(InstrumentationConfigurationSection configurationSection, IRegistryKey policyKey) { bool?eventLoggingEnabledOverride = policyKey.GetBoolValue(EventLoggingEnabledPropertyName); bool?performanceCountersEnabledOverride = policyKey.GetBoolValue(PerformanceCountersEnabledPropertyName); configurationSection.EventLoggingEnabled = eventLoggingEnabledOverride.Value; configurationSection.PerformanceCountersEnabled = performanceCountersEnabledOverride.Value; }
/// <summary> /// Overrides the <paramref name="configurationSection"/>'s properties with the Group Policy values from /// the registry. /// </summary> /// <param name="configurationSection">The configuration section that must be managed.</param> /// <param name="policyKey">The <see cref="IRegistryKey"/> which holds the Group Policy overrides.</param> protected override void OverrideWithGroupPoliciesForConfigurationSection(LoggingSettings configurationSection, IRegistryKey policyKey) { String defaultCategoryOverride = policyKey.GetStringValue(DefaultCategoryPropertyName); bool? tracingEnabledEnabledOverride = policyKey.GetBoolValue(TracingEnabledPropertyName); bool? logWarningWhenNoCategoriesMatchOverride = policyKey.GetBoolValue(LogWarningOnNoMatchPropertyName); configurationSection.DefaultCategory = defaultCategoryOverride; configurationSection.TracingEnabled = tracingEnabledEnabledOverride.Value; configurationSection.LogWarningWhenNoCategoriesMatch = logWarningWhenNoCategoriesMatchOverride.Value; }
bool OverrideWithGroupPoliciesForOracleConnection(OracleConnectionData connectionData, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey ?? userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { String packagesOverride = policyKey.GetStringValue(PackagesPropertyName); connectionData.Packages.Clear(); Dictionary <String, String> packagesDictionary = new Dictionary <string, string>(); KeyValuePairParser.ExtractKeyValueEntries(packagesOverride, packagesDictionary); foreach (KeyValuePair <String, String> kvp in packagesDictionary) { connectionData.Packages.Add(new OraclePackageData(kvp.Key, kvp.Value)); } } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } return(true); }
public override bool OverrideWithGroupPolicies(ConfigurationSection configurationObject, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { called = true; this.configurationObject = configurationObject; this.readGroupPolicies = readGroupPolicies; this.machineKey = machineKey; this.userKey = userKey; IRegistryKey policyKey = GetPolicyKey(machineKey, userKey); if (policyKey != null) { if (!policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } TestsConfigurationSection section = configurationObject as TestsConfigurationSection; if (section != null) { try { section.Value = policyKey.GetStringValue(ValuePropertyName); } catch (RegistryAccessException) { } } } return(true); }
public override bool OverrideWithGroupPoliciesAndGenerateWmiObjects(ConfigurationElement configurationObject, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { called = true; configurationObjects.Add(configurationObject); this.readGroupPolicies = readGroupPolicies; this.machineKey = machineKey; this.userKey = userKey; this.generateWmiObjects = generateWmiObjects; if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null && policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } } if (generateWmiObjects) { wmiSettings.Add(new TestConfigurationSettings(configurationObject.ToString())); } return(true); }
private bool OverrideWithGroupPoliciesAndGenerateWmiObjectsForConnectionString(ConnectionStringSettings connectionString, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey ?? userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { String connectionStringOverride = policyKey.GetStringValue(ConnectionStringPropertyName); String providerNameOverride = policyKey.GetStringValue(ProviderNamePropertyName); connectionString.ConnectionString = connectionStringOverride; connectionString.ProviderName = providerNameOverride; } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } if (generateWmiObjects) { ConnectionStringsWmiMapper.GenerateConnectionStringWmiObjects(connectionString, wmiSettings); } return(true); }
private bool OverrideWithGroupPoliciesAndGenerateWmiObjectsForDbProviderMapping(DbProviderMapping providerMapping, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { Type databaseTypeOverride = policyKey.GetTypeValue(DatabaseTypePropertyName); providerMapping.DatabaseType = databaseTypeOverride; } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } if (generateWmiObjects) { wmiSettings.Add( new ProviderMappingSetting(providerMapping.DbProviderName, providerMapping.DatabaseType.AssemblyQualifiedName)); } return(true); }
private bool OverrideWithGroupPoliciesForDbProviderMapping(DbProviderMapping providerMapping, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey ?? userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { Type databaseTypeOverride = policyKey.GetTypeValue(DatabaseTypePropertyName); providerMapping.DatabaseType = databaseTypeOverride; } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } return(true); }
private bool OverrideWithGroupPoliciesForConnectionString(ConnectionStringSettings connectionString, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey ?? userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { String connectionStringOverride = policyKey.GetStringValue(ConnectionStringPropertyName); String providerNameOverride = policyKey.GetStringValue(ProviderNamePropertyName); connectionString.ConnectionString = connectionStringOverride; connectionString.ProviderName = providerNameOverride; } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } return(true); }
/// <summary> /// Overrides the <paramref name="configurationObject"/>'s properties with the Group Policy values from the /// registry. /// </summary> /// <param name="configurationObject">The configuration object for instances that must be managed.</param> /// <param name="policyKey">The <see cref="IRegistryKey"/> which holds the Group Policy overrides for the /// configuration element.</param> /// <remarks>Subclasses implementing this method must retrieve all the override values from the registry /// before making modifications to the <paramref name="configurationObject"/> so any error retrieving /// the override values will cancel policy processing.</remarks> protected override void OverrideWithGroupPolicies(LogEnabledFilterData configurationObject, IRegistryKey policyKey) { bool?enabledOverride = policyKey.GetBoolValue(EnabledPropertyName); configurationObject.Enabled = enabledOverride.Value; }
private bool OverrideWithGroupPoliciesForDbProviderMapping( DbProviderMapping providerMapping, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { if (readGroupPolicies) { IRegistryKey registryKey = machineKey ?? userKey; if (registryKey != null) { if (registryKey.IsPolicyKey) { if (!registryKey.GetBoolValue("Available").Value) { return(false); } } try { Type typeValue = registryKey.GetTypeValue("databaseType"); providerMapping.DatabaseType = typeValue; } catch (RegistryAccessException ex) { this.LogExceptionWhileOverriding((Exception)ex); } } } return(true); }
private bool OverrideWithGroupPoliciesForConfigurationSection(T configurationSection, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { if (readGroupPolicies) { IRegistryKey policyKey = GetPolicyKey(machineKey, userKey); if (policyKey != null) { if (!policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { OverrideWithGroupPoliciesForConfigurationSection(configurationSection, policyKey); } catch (Exception ex) { LogExceptionWhileOverriding(ex); } } } return(true); }
protected internal override bool OverrideWithGroupPoliciesAndGenerateWmiObjects(ConfigurationSection configurationObject, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { called = true; this.configurationObject = configurationObject; this.readGroupPolicies = readGroupPolicies; this.machineKey = machineKey; this.userKey = userKey; this.generateWmiObjects = generateWmiObjects; IRegistryKey policyKey = GetPolicyKey(machineKey, userKey); if (policyKey != null && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } if (generateWmiObjects) { wmiSettings.Add(new TestConfigurationSettings(configurationObject.ToString())); } return(true); }
private bool OverrideWithGroupPoliciesForConnectionString( ConnectionStringSettings connectionString, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { if (readGroupPolicies) { IRegistryKey registryKey = machineKey ?? userKey; if (registryKey != null) { if (registryKey.IsPolicyKey) { if (!registryKey.GetBoolValue("Available").Value) { return(false); } } try { string stringValue1 = registryKey.GetStringValue(nameof(connectionString)); string stringValue2 = registryKey.GetStringValue("providerName"); connectionString.ConnectionString = stringValue1; connectionString.ProviderName = stringValue2; } catch (RegistryAccessException ex) { this.LogExceptionWhileOverriding((Exception)ex); } } } return(true); }
private bool OverrideWithGroupPoliciesForTraceSource( TraceSourceData traceSourceData, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, String sourceKind) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { SourceLevels?defaultLevelOverride = policyKey.GetEnumValue <SourceLevels>(SourceDefaultLevelPropertyName); bool? autoFlushOverride = policyKey.GetBoolValue(SourceAutoFlushPropertyName); // the key where the values for the source listeners are stored // might not exist if no listener is selected traceSourceData.TraceListeners.Clear(); using (IRegistryKey listenersOverrideKey = policyKey.OpenSubKey(SourceTraceListenersPropertyName)) { if (listenersOverrideKey != null) { foreach (String valueName in listenersOverrideKey.GetValueNames()) { traceSourceData.TraceListeners.Add(new TraceListenerReferenceData(valueName)); } } } traceSourceData.DefaultLevel = defaultLevelOverride.Value; traceSourceData.AutoFlush = autoFlushOverride.Value; } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } return(true); }
protected override void OverrideWithGroupPolicies(HashAlgorithmProviderData configurationObject, IRegistryKey policyKey) { bool?saltEnabledOverride = policyKey.GetBoolValue(SaltEnabledPropertyName); // algorithm type is read only in the configuration tool configurationObject.SaltEnabled = saltEnabledOverride.Value; }
private bool OverrideWithGroupPoliciesAndGenerateWmiObjectsForTraceSource(TraceSourceData traceSourceData, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings, String sourceKind) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { SourceLevels?defaultLevelOverride = policyKey.GetEnumValue <SourceLevels>(SourceDefaultLevelPropertyName); // the key where the values for the source listeners are stored // might not exist if no listener is selected traceSourceData.TraceListeners.Clear(); using (IRegistryKey listenersOverrideKey = policyKey.OpenSubKey(SourceTraceListenersPropertyName)) { if (listenersOverrideKey != null) { foreach (String valueName in listenersOverrideKey.GetValueNames()) { traceSourceData.TraceListeners.Add(new TraceListenerReferenceData(valueName)); } } } traceSourceData.DefaultLevel = defaultLevelOverride.Value; } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } if (generateWmiObjects) { String[] referencedTraceListeners = new String[traceSourceData.TraceListeners.Count]; for (int i = 0; i < traceSourceData.TraceListeners.Count; i++) { referencedTraceListeners[i] = traceSourceData.TraceListeners.Get(i).Name; } wmiSettings.Add( new TraceSourceSetting( traceSourceData.Name, traceSourceData.DefaultLevel.ToString(), referencedTraceListeners, sourceKind)); } return(true); }
private bool OverrideWithGroupPolicyTypeTypesAndGenerateWmiObjectsForPolicyType(ExceptionTypeData exceptionType, ExceptionPolicyData parentPolicy, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { PostHandlingAction?postHandlingActionOverride = policyKey.GetEnumValue <PostHandlingAction>(PolicyTypePostHandlingActionPropertyName); exceptionType.PostHandlingAction = postHandlingActionOverride.Value; } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } if (generateWmiObjects) { ExceptionTypeSetting wmiSetting = new ExceptionTypeSetting(exceptionType.Name, exceptionType.Type.AssemblyQualifiedName, exceptionType.PostHandlingAction.ToString()); wmiSetting.Policy = parentPolicy.Name; wmiSettings.Add(wmiSetting); } List <ConfigurationSetting> handlerSettings = new List <ConfigurationSetting>(exceptionType.ExceptionHandlers.Count); OverrideWithGroupPoliciesAndGenerateWmiObjectsForElementCollection(exceptionType.ExceptionHandlers, PolicyTypeHandlersPropertyName, readGroupPolicies, machineKey, userKey, generateWmiObjects, handlerSettings); int i = 0; foreach (ExceptionHandlerSetting setting in handlerSettings) { setting.Policy = parentPolicy.Name; setting.ExceptionType = exceptionType.Name; setting.Order = i++; wmiSettings.Add(setting); } return(true); }
private bool OverrideWithGroupPolicyTypeTypesAndGenerateWmiObjectsForPolicyType(ExceptionTypeData exceptionType, ExceptionPolicyData parentPolicy, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { PostHandlingAction?postHandlingActionOverride = policyKey.GetEnumValue <PostHandlingAction>(PolicyTypePostHandlingActionPropertyName); exceptionType.PostHandlingAction = postHandlingActionOverride.Value; } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } if (generateWmiObjects) { ExceptionHandlingSettingsWmiMapper.GenerateExceptionTypeWmiObjects(exceptionType, parentPolicy, wmiSettings); } // Note: store the handler settings to a temporary location to enable // post processing. This forces the creation of a specific interface and // fixes the schema. List <ConfigurationSetting> handlerSettings = new List <ConfigurationSetting>(exceptionType.ExceptionHandlers.Count); OverrideWithGroupPoliciesAndGenerateWmiObjectsForElementCollection(exceptionType.ExceptionHandlers, PolicyTypeHandlersPropertyName, readGroupPolicies, machineKey, userKey, generateWmiObjects, handlerSettings); int i = 0; foreach (ExceptionHandlerSetting setting in handlerSettings) { setting.Policy = parentPolicy.Name; setting.ExceptionType = exceptionType.Name; setting.Order = i++; // add the post-processed handler settings to the main settings collection wmiSettings.Add(setting); } return(true); }
protected override void OverrideWithGroupPolicies(KeyedHashAlgorithmProviderData configurationObject, IRegistryKey policyKey) { bool? saltEnabledOverride = policyKey.GetBoolValue(SaltEnabledPropertyName); String protectedKeyFilenameOverride = policyKey.GetStringValue(ProtectedKeyFilenamePropertyName); DataProtectionScope?protectedKeyProtectionScopeOverride = policyKey.GetEnumValue <DataProtectionScope>(ProtectedKeyProtectionScopePropertyName); // algorithm type is read only in the configuration tool configurationObject.SaltEnabled = saltEnabledOverride.Value; configurationObject.ProtectedKeyFilename = protectedKeyFilenameOverride; configurationObject.ProtectedKeyProtectionScope = protectedKeyProtectionScopeOverride.Value; }
bool OverrideWithGroupPoliciesAndGenerateWmiObjectsForCacheManager(CacheManagerDataBase cacheManagerDataBase, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { if (cacheManagerDataBase is CacheManagerData) { CacheManagerData cacheManagerData = (CacheManagerData)cacheManagerDataBase; // cache storage is not overrideable int?expirationPollFrequencyInSecondsOverride = policyKey.GetIntValue(CacheManagerExpirationPollFrequencyInSecondsPropertyName); int?maximumElementsInCacheBeforeScavengingOverride = policyKey.GetIntValue(CacheManagerMaximumElementsInCacheBeforeScavengingPropertyName); int?numberToRemoveWhenScavengingOverride = policyKey.GetIntValue(CacheManagerNumberToRemoveWhenScavengingPropertyName); cacheManagerData.ExpirationPollFrequencyInSeconds = expirationPollFrequencyInSecondsOverride.Value; cacheManagerData.MaximumElementsInCacheBeforeScavenging = maximumElementsInCacheBeforeScavengingOverride.Value; cacheManagerData.NumberToRemoveWhenScavenging = numberToRemoveWhenScavengingOverride.Value; } } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } if (generateWmiObjects) { CacheManagerSettingsWmiMapper.GenerateCacheManagerWmiObjects(cacheManagerDataBase, wmiSettings); } return(true); }
/// <summary> /// Overrides the <paramref name="configurationObject"/>'s properties with the Group Policy values from the /// registry, if any, and creates the <see cref="ConfigurationSetting"/> instances that describe the /// configurationObject. /// </summary> /// <param name="configurationObject">The configuration object for instances that must be managed.</param> /// <param name="readGroupPolicies"><see langword="true"/> if Group Policy overrides must be applied; otherwise, /// <see langword="false"/>.</param> /// <param name="machineKey">The <see cref="IRegistryKey"/> which holds the Group Policy overrides for the /// configuration element at the machine level, or <see langword="null"/> /// if there is no such registry key.</param> /// <param name="userKey">The <see cref="IRegistryKey"/> which holds the Group Policy overrides for the /// configuration element at the user level, or <see langword="null"/> /// if there is no such registry key.</param> /// <param name="generateWmiObjects"><see langword="true"/> if WMI objects must be generated; otherwise, /// <see langword="false"/>.</param> /// <param name="wmiSettings">A collection to where the generated WMI objects are to be added.</param> /// <returns><see langword="true"/> if the policy settings do not disable the configuration element, otherwise /// <see langword="false"/>.</returns> /// <exception cref="ArgumentException">when the type of <paramref name="configurationObject"/> is not /// the type <typeparamref name="T"/>.</exception> /// <remarks> /// Provides a default implementation that performs appropriate logging of errors when processing /// policy overrides. /// </remarks> /// <seealso cref="ConfigurationElementManageabilityProvider.OverrideWithGroupPoliciesAndGenerateWmiObjects">ConfigurationElementManageabilityProvider.OverrideWithGroupPoliciesAndGenerateWmiObjects</seealso> /// <seealso cref="ConfigurationElementManageabilityProviderBase{T}.OverrideWithGroupPolicies"/> /// <seealso cref="ConfigurationElementManageabilityProviderBase{T}.GenerateWmiObjects"/> protected internal sealed override bool OverrideWithGroupPoliciesAndGenerateWmiObjects(ConfigurationElement configurationObject, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { T data = configurationObject as T; if (data == null) { throw new ArgumentException( String.Format(CultureInfo.CurrentUICulture, Resources.ConfigurationElementOfWrongType, typeof(T).FullName, configurationObject.GetType().FullName), "configurationObject"); } if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null) { // the keys for some elements might not be the keys associated to a policy, // but hold the policy values for the element when policies for multiple // elements are combined. if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { OverrideWithGroupPolicies(data, policyKey); } catch (Exception ex) { LogExceptionWhileOverriding(ex); } } } if (generateWmiObjects) { GenerateWmiObjects(data, wmiSettings); } return(true); }
private bool OverrideWithGroupPoliciesAndGenerateWmiObjectsForOracleConnection(OracleConnectionData connectionData, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { String packagesOverride = policyKey.GetStringValue(PackagesPropertyName); connectionData.Packages.Clear(); Dictionary <String, String> packagesDictionary = new Dictionary <string, string>(); KeyValuePairParser.ExtractKeyValueEntries(packagesOverride, packagesDictionary); foreach (KeyValuePair <String, String> kvp in packagesDictionary) { connectionData.Packages.Add(new OraclePackageData(kvp.Key, kvp.Value)); } } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } if (generateWmiObjects) { String[] packages = GeneratePackagesArray(connectionData.Packages); wmiSettings.Add(new OracleConnectionSetting(connectionData.Name, packages)); } return(true); }
private bool OverrideWithGroupPoliciesForOracleConnection( OracleConnectionData connectionData, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { if (readGroupPolicies) { IRegistryKey registryKey = machineKey ?? userKey; if (registryKey != null) { if (registryKey.IsPolicyKey) { if (!registryKey.GetBoolValue("Available").Value) { return(false); } } try { string stringValue = registryKey.GetStringValue("packages"); connectionData.Packages.Clear(); Dictionary <string, string> dictionary = new Dictionary <string, string>(); KeyValuePairParser.ExtractKeyValueEntries(stringValue, (IDictionary <string, string>)dictionary); foreach (KeyValuePair <string, string> keyValuePair in dictionary) { connectionData.Packages.Add(new OraclePackageData(keyValuePair.Key, keyValuePair.Value)); } } catch (RegistryAccessException ex) { this.LogExceptionWhileOverriding((Exception)ex); } } } return(true); }
public override bool OverrideWithGroupPoliciesAndGenerateWmiObjects(ConfigurationSection configurationObject, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey, bool generateWmiObjects, ICollection <ConfigurationSetting> wmiSettings) { called = true; this.configurationObject = configurationObject; this.readGroupPolicies = readGroupPolicies; this.machineKey = machineKey; this.userKey = userKey; this.generateWmiObjects = generateWmiObjects; IRegistryKey policyKey = GetPolicyKey(machineKey, userKey); if (policyKey != null) { if (!policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } TestsConfigurationSection section = configurationObject as TestsConfigurationSection; if (section != null) { try { section.Value = policyKey.GetStringValue(ValuePropertyName); } catch (RegistryAccessException) { } } } if (generateWmiObjects) { TestConfigurationSettings setting = new TestConfigurationSettings(configurationObject.ToString()); setting.SourceElement = configurationObject; wmiSettings.Add(setting); } return(true); }
public override bool OverrideWithGroupPolicies(ConfigurationElement configurationObject, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { called = true; configurationObjects.Add(configurationObject); this.readGroupPolicies = readGroupPolicies; this.machineKey = machineKey; this.userKey = userKey; if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null && policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } } return(true); }
private bool OverrideWithGroupPolicyTypeTypesForPolicyType(ExceptionTypeData exceptionType, ExceptionPolicyData parentPolicy, bool readGroupPolicies, IRegistryKey machineKey, IRegistryKey userKey) { if (readGroupPolicies) { IRegistryKey policyKey = machineKey != null ? machineKey : userKey; if (policyKey != null) { if (policyKey.IsPolicyKey && !policyKey.GetBoolValue(PolicyValueName).Value) { return(false); } try { PostHandlingAction?postHandlingActionOverride = policyKey.GetEnumValue <PostHandlingAction>(PolicyTypePostHandlingActionPropertyName); exceptionType.PostHandlingAction = postHandlingActionOverride.Value; } catch (RegistryAccessException ex) { LogExceptionWhileOverriding(ex); } } } // Note: store the handler settings to a temporary location to enable // post processing. This forces the creation of a specific interface and // fixes the schema. OverrideWithGroupPoliciesForElementCollection(exceptionType.ExceptionHandlers, PolicyTypeHandlersPropertyName, readGroupPolicies, machineKey, userKey); return(true); }