ManageableConfigurationSource with Group Policy (Ent Lib 5.0)

Topics: Building and extending application blocks, Enterprise Library Core, Exception Handling Application Block, Logging Application Block
Aug 2, 2012 at 8:31 AM
Edited Aug 2, 2012 at 8:31 AM

I have followed the article here; to store certain configuration details for my app using Group Policy.

I have no issues getting my templates imported and administerable from the Group Policy manager, however I could not find or work out how to retrieve the values stored in the registry from my application using the Ent Lib API. Or am I just supposed to use native .NET to retrieve these values?

How do i use the IConfigurationSource, ManageableConfigurationSource, ManageableConfigurationSourceImplementation classes with the Group Policy watcher? Do I still need to reference a local configuration file? Some sample code would be great!!

I want to do something along the lines of;

var manageableConfigurationSourceImplementation = new ManageableConfigurationSourceImplementation(configurationFilePath, manageabilityHelper, groupPolicyWatcher, watcherCoordinator, notificationCoordinator);

IConfigurationSource source = new ManageableConfigurationSource(manageableConfigurationSourceImplementation);

source.SourceChanged += MyConfigChangedEventHandler;


Aug 2, 2012 at 10:30 AM

Once you have everything configured, then the configuration policies should "just work" by accessing the standard Enterprise Library APIs (container and static facades).  

Yes, you still need the local configuration file reference.  First the local configuration file is read and then the group policies are applied on top overriding any local configuration.  ASP.NET Configuration and Group Policy, Part 3: Using the Enterprise Library Manageable Configuration Extensions is a good article.  It's old but it should still apply for the most part.

My gut reaction would be to stay away from using the ManageableConfigurationSourceImplementation class unless it is absolutely necessary since it is an internal implementation class.  You would need to verify that it is being used properly and also it could change in future releases of Enterprise Library.

Can you use the ManageableConfigurationSource:

        public ManageableConfigurationSource(
            string configurationFilePath,
            IDictionary<string, ConfigurationSectionManageabilityProvider> manageabilityProviders,
            bool readGroupPolicies,
            string applicationName)

And then add a section handler:

    var configSource = new ManageableConfigurationSource(configFilePath, manageabilityProviders, true, "MyApp");
    configSource.AddSectionChangeHandler(LoggingSettings.SectionName, new ConfigurationChangedEventHandler(
        (o, e) =>
            var coordinator = o as ConfigurationChangeNotificationCoordinator;

I'm not sure if SourceChanged hooks into the coordinator in this case.

Randy Levy
Enterprise Library support engineer