Policy Feature Definitions
A policy feature definition is a section of XML that provides the information Microsoft Office SharePoint Server 2007 requires to do the following:
Include the creation and configuration of the policy item in the Office SharePoint Server 2007 Central Administration interface.
Call the policy feature code for tasks such as initializing the policy feature.
To facilitate creation and configuration of the policy item, the Policy Feature Definition can include the URL addresses of two Web controls: one for server farm-level policy feature settings, and the other for policy instance-level policy feature settings. These Web controls are hosted within Office SharePoint Server 2007 and enable the appropriate users to set settings at the appropriate levels.
Specifying Global Custom Settings Control
The server farm-level Web control is hosted on the administration page for that policy feature, and enables administrators to specify settings for the policy feature for the entire server farm. These settings, referred to as global settings, cannot be viewed or changed by users who are not administrators. The global settings are saved within the Policy Feature Definition itself. For example, the Bar Code policy feature contains a global setting that lets the server administrator select the bar code generator to use with the policy feature.
The server farm-level Web control must implement the GlobalCustomSettingsControl class.
If you do not specify a global custom settings control, administrators do not have the ability to overwrite or edit the default global data specified for the policy feature, and therefore lack the ability to customize the feature at the administrator level. This limits the administrator's options to either activating the policy feature, or not.
Specifying Custom Settings Control
The policy instance-level Web control is hosted on the policy item customization page, because it enables the user to specify custom settings that apply to the policy feature within a specific policy. These custom settings are saved within the specific policy’s policy item for that policy feature. For example, the Bar Code policy feature contains the following settings that the user can specify for each policy in which the policy feature appears:
Automatically provide bar codes.
Prompt user to include bar codes in documents.
The policy instance-level Web control must implement the CustomSettingsControl class.
If you do not specify a custom settings control, users do not have the ability to overwrite or edit the default data specified for the policy feature, and therefore lack the ability to customize the feature at the end-user level.
Specifying Feature Assembly and Class
For Office SharePoint Server 2007 to be able to call the policy feature code itself to perform required tasks such as initialization, the Policy Feature Definition must contain two specific pointers: one to the location of the strong-named policy feature assembly in the global assembly cache, and one to the class within that assembly that implements the IPolicyFeature interface.
For more information about the IPolicyFeature interface, see IPolicyFeature Interface Overview.
Specifying Policy Resources
If a policy feature uses policy resources, it must list the type of resources it uses in its Policy Feature Definition. For example, the Bar Code policy feature includes in its Policy Feature Definition an element indicating it uses policy resources of type "Bar Code Generator". The policy feature can then use any resource that declares in its Resource Definition that it is of type "Barcode Generator". The policy resource name must be fully qualified and appear on the Policy Resource Definition List for that policy feature.
Policy resources can be specified as required, or optional within the Policy Feature Definition. If you install a policy feature that requires a policy resource of a specific type, and no policy resources of that type are installed on the farm, then you cannot activate that policy feature.
The following figure shows the information contained within the Policy Feature Definition, and the items that the information references.
Adding a Policy Feature Definition to the Policy Feature List
The Policy Feature List includes the Policy Feature Definitions for each policy feature installed on a specified server farm. You can add a site policy by calling the Add method of the PolicyFeatureCollection class. This method adds the XML passed to it to the Policy Feature List as the Policy Feature Definition for the policy feature.
This is usually done as part of deploying the policy feature as a Windows SharePoint Services Feature. For more information, see Working with Features in the Microsoft Windows SharePoint Services 3.0 SDK.
After you add a Policy Feature Definition to the Policy Feature List, you can work with the policy feature programmatically, as a PolicyFeature object in the object model. For more information, see Policy Namespace Overview.