void DoUpdateConfigurationSectionManageability(IConfigurationAccessor configurationAccessor,
                                                       String sectionName)
        {
            ConfigurationSectionManageabilityProvider manageabilityProvider = manageabilityProviders[sectionName];

            ConfigurationSection section = configurationAccessor.GetSection(sectionName);

            if (section != null)
            {
                IRegistryKey machineKey = null;
                IRegistryKey userKey    = null;

                try
                {
                    LoadPolicyRegistryKeys(sectionName, out machineKey, out userKey);

                    if (!manageabilityProvider
                        .OverrideWithGroupPolicies(section, readGroupPolicies, machineKey, userKey))
                    {
                        configurationAccessor.RemoveSection(sectionName);
                    }
                }
                catch (Exception e)
                {
                    ManageabilityExtensionsLogger.LogException(e, Resources.ExceptionUnexpectedErrorProcessingSection);
                }
                finally
                {
                    ReleasePolicyRegistryKeys(machineKey, userKey);
                }
            }
        }
Example #2
0
        public void UpdateConfigurationManageability(IConfigurationAccessor configurationAccessor)
        {
            using (new GroupPolicyLock())
            {
                foreach (String sectionName in manageabilityProviders.Keys)
                {
                    if (publishedSettingsMapping.ContainsKey(sectionName))
                    {
                        RevokeAll(publishedSettingsMapping[sectionName]);
                    }

                    ConfigurationSectionManageabilityProvider manageabilityProvider = manageabilityProviders[sectionName];

                    ConfigurationSection section = configurationAccessor.GetSection(sectionName);
                    if (section != null)
                    {
                        ICollection <ConfigurationSetting> wmiSettings = new List <ConfigurationSetting>();

                        IRegistryKey machineKey = null;
                        IRegistryKey userKey    = null;

                        try
                        {
                            LoadPolicyRegistryKeys(sectionName, out machineKey, out userKey);

                            if (manageabilityProvider
                                .OverrideWithGroupPoliciesAndGenerateWmiObjects(section,
                                                                                this.readGroupPolicies, machineKey, userKey,
                                                                                generateWmiObjects, wmiSettings))
                            {
                                publishedSettingsMapping[sectionName] = wmiSettings;

                                PublishAll(wmiSettings, sectionName);
                            }
                            else
                            {
                                configurationAccessor.RemoveSection(sectionName);
                            }
                        }
                        catch (Exception e)
                        {
                            ManageabilityExtensionsLogger.LogException(e, Resources.ExceptionUnexpectedErrorProcessingSection);
                        }
                        finally
                        {
                            ReleasePolicyRegistryKeys(machineKey, userKey);
                        }
                    }
                }
            }                   // locks on group policies are released here
        }