Querying and Updating the WMI Repository
You can use Windows Management Instrumentation (WMI) to view and update a running application's configuration data when you use the Manageable Configuration Source to expose your Enterprise Library configuration. The Manageable Configuration Source reads information from the configuration file, applies any applicable Group Policy overrides, and exposes the configuration information to applications as a series of configuration class instances in the same way as the other Enterprise Library configuration sources.
However, the Manageable Configuration Source also exposes the configuration information through the .NET WMI 2.0 API and to the WMI Repository as a set of WMI classes that you can query and view. This allows administrators and users to examine configuration information using standard Windows-based management tools or code.
In addition, administrators and users can update the values of the WMI objects using standard Windows-based management tools or code. These changes update the configuration information exposed to the application by the Manageable Configuration Source, which also raises a ConfigurationChanged event that allows the application to react to the changes and reload the new configuration values.
Note:
You must have the relevant Windows permissions to update WMI objects. In addition, as changes pass back to the Manageable Configuration Source, it reapplies any relevant Group Policy overrides. If the change conflicts with a Group Policy setting, the Manageable Configuration Source will ignore the change and continue to expose the Group Policy-applied value.
Changes you make to the configuration exposed by the WMI objects are exposed by the Manageable Configuration Source and are visible in the application. However, they do not change the contents of the original configuration file. When the application restarts, or if you make changes to the configuration file contents, any updates made through WMI are lost.
The following table lists the ways you can query and update values in the WMI Repository.
Posted in: .Net Programming| Tags: Application Configuration Enterprise Library Group Manageable Policy Query Repository Source Update WMI file information managementUsing Group Policy with Enterprise Library
To use Group Policy to manage an Enterprise Library application, you must first generate a Group Policy template and then use Group Policy to configure the application. Although the procedures in this section use the Configuration Console, you can use the same procedures with the Configuration Editor that is integrated with Visual Studio.
To generate a Group Policy template for the application
Ensure that you have completed all other configuration tasks for the application.
Open the Configuration Console.
In the left pane of the Enterprise Library Configuration Console, right-click Manageable Configuration Source, and then click Generate ADM Template.
In the Save As box, type a name for the template, and then click Save.
Note:
The templates generated by the configuration tools use the Windows Server 2003 ADM format for maximum compatibility with all existing operating system versions. Windows Vista and Windows Server 2008 use the new ADMX format for Group Policy templates. However, they will also read and use ADM format templates.
To configure the application using Group Policy
Ensure that you have administrative privileges to configure the application.
Ensure that you have installed a suitable version of the Group Policy Management Console (GPMC), as shown in the following list:
Windows Server 2008 includes the GPMC.
For Windows Vista SP1, download and install the Remote Server Administration Tools from the Microsoft Download Center.
For Windows Server 2003 and Windows XP Service Pack 2, download and install the Group Policy Management Console with Service Pack 1 from the Microsoft Download Center.
Click Start, and then click Run. In the Run dialog box, type gpmc.msc, and then click OK. This opens the Group Policy Management Console (GPMC) and shows the complete forest for your domain.
Expand the Domains node to show the Group Policy Objects section within your domain.
Right-click Group Policy Objects, click New, type a name for the new Group Policy Object, and then click OK.
In the left tree view, right-click your new Group Policy Object entry, and then click Edit.
Expand the Computer Configuration or User Configuration section of the Group Policy Object. Right-click Administrative Templates, and then click Add/Remove Templates.
In the Add/Remove templates dialog box, click Add.
Browse to the template you created in the Enterprise Library Configuration Console, select it, and then click Open. The template appears in the Add/Remove templates dialog box.
In the Add/Remove templates dialog box, click Close.
Expand the Administrative Templates section, and then locate the section corresponding to the template that you just added. Expand this section and each section within it. As you select a section, the settings available for that section appear in the right-side window.
To open the Settings dialog box, double-click the setting you want to edit.
The Settings dialog box allows you to enter an initial value if you have not already configured it, or enable or disable an existing setting.
When you select Enabled, the controls in the central section of the dialog box allow you to specify the setting. Depending on the type of value and the way the ADM file declares the setting details, you will see a text box, a drop-down list, or another standard Windows control.
Use the Previous Setting and Next Setting buttons to navigate through the settings without having to open each one individually from the main Group Policy window or click OK to commit this setting and close the Settings dialog box.
Adding a Manageable Configuration Source
If you want to use Group Policy or Windows Management Instrumentation (WMI) with an application, you must first add a manageable configuration source. Although the procedures shown here use the Configuration Console, you can use the same procedures with the Configuration Editor that is integrated with Visual Studio. For more information about the Configuration Editor, see Using the Configuration Tools.
To add a manageable configuration source
Start the Enterprise Library Configuration Console or the Visual Studio Configuration Editor. To use the Configuration Console, click Start, point to All Programs, point to Microsoft patterns & practices, point to Enterprise Library 4.1 – October 2008, and then click Enterprise Library Configuration.
Click New Application or Open Existing Application.
Right-click the application configuration file listed under Enterprise Library Configuration, point to New, and then click Configuration Sources.
Right-click the Configuration Sources node, point to New, and then click Manageable Configuration Source.
Click the Configuration Sources node.
In the right pane, click SelectedSource.
In the drop-down list, click Manageable Configuration Source.
Click the Manageable Configuration Source node. In the right pane, set the configuration settings. By default, both WMI and Group Policy are enabled. You must provide an entry for the File property.
Right-click the System Configuration Source, and then click Remove.
On the File menu, click Save Application.
Changes to the Policy Injection Application Block
The following changes have been made to this version of the Policy Injection Application Block:
- Fixed : Design time for the policy injector collection now reads the default injector from the configuration file. The node creation classes are updated to set the default injector node property on the injectors collection node.
- Changed : The matching classes implementation has changed. The implementation was moved to Unity. The classes still exist in the Policy Injection Application Block as configuration placeholders to provide backward compatibility.
- Changed : The Policy Injection Application Block can now use a container. The container is configured with the Policy Injection Application Block configuration.
- Changed : The Policy Injection Application Block now has only the default interceptor. Non-default interceptor options have been removed. The <injectors> element has been removed. The default interception mechanism of the Policy Injection Application Block enables you to reuse existing object instances.
- Changed Remoting Interception has been renamed Transparent Proxy Interception.