Policy Class

The Policy object represents a Policy-Based Management policy. A policy represents the relationship between a target object and a condition.

Inheritance Hierarchy

System.Object
  Microsoft.SqlServer.Management.Sdk.Sfc.SfcInstance
    Microsoft.SqlServer.Management.Dmf.Policy

Namespace:  Microsoft.SqlServer.Management.Dmf
Assembly:  Microsoft.SqlServer.Dmf (in Microsoft.SqlServer.Dmf.dll)

Syntax

'Declaration
<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey := "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")> _
<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey := "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")> _
Public NotInheritable Class Policy _
    Inherits SfcInstance _
    Implements ISfcCreatable, ICreatable, ISfcDroppable, IDroppable,  _
    ISfcAlterable, IAlterable, ISfcRenamable, IRenamable, ISfcValidate
'Usage
Dim instance As Policy
[StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
[StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
public sealed class Policy : SfcInstance, 
    ISfcCreatable, ICreatable, ISfcDroppable, IDroppable, ISfcAlterable, 
    IAlterable, ISfcRenamable, IRenamable, ISfcValidate
[StrongNameIdentityPermissionAttribute(SecurityAction::LinkDemand, PublicKey = L"0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
[StrongNameIdentityPermissionAttribute(SecurityAction::LinkDemand, PublicKey = L"0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
public ref class Policy sealed : public SfcInstance, 
    ISfcCreatable, ICreatable, ISfcDroppable, IDroppable, ISfcAlterable, 
    IAlterable, ISfcRenamable, IRenamable, ISfcValidate
[<SealedAttribute>]
[<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")>]
[<StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")>]
type Policy =  
    class
        inherit SfcInstance
        interface ISfcCreatable
        interface ICreatable
        interface ISfcDroppable
        interface IDroppable
        interface ISfcAlterable
        interface IAlterable
        interface ISfcRenamable
        interface IRenamable
        interface ISfcValidate
    end
public final class Policy extends SfcInstance implements ISfcCreatable, ICreatable, ISfcDroppable, IDroppable, ISfcAlterable, IAlterable, ISfcRenamable, IRenamable, ISfcValidate

The Policy type exposes the following members.

Constructors

  Name Description
Public method Policy() Initializes a new instance of the Policy class.
Public method Policy(PolicyStore, String) Initializes a new instance of the Policy class.

Top

Properties

  Name Description
Protected property AbstractIdentityKey Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public property AutomatedPolicyEvaluationMode Gets or sets the evaluation mode.
Public property CategoryId Gets the ID value that uniquely identifies the category that is associated with the policy.
Public property Condition Gets or sets the condition.
Public property CreateDate Gets the date and time when the policy was created.
Public property CreatedBy Gets the policy store authentication credentials of the user who created the policy.
Public property DateModified Gets the date and time when the policy was last modified.
Public property Description Gets or sets the textual description of the policy.
Public property Enabled Gets or set the Boolean value that specifies whether the policy is enabled.
Public property EvaluationHistories Gets the evaluation histories collection.
Public property HasScript Gets the Boolean value that specifies whether the policy has a script.
Public property HelpLink Gets or sets a URN to additional help information for the policy.
Public property HelpText Gets or sets the display name for the help text.
Public property ID Gets the ID value that uniquely identifies the policy.
Public property IdentityKey Gets the key that identifies the policy.
Public property IsSystemObject Determines whether the Policy object is a Object.
Public property Metadata Returns metadata about the instance and its domain. (Inherited from SfcInstance.)
Public property ModifiedBy Gets the policy store authentication credentials of the user who last modified the policy.
Public property Name Gets the name of the Policy object.
Public property ObjectSet Gets or sets the set of objects that are associated with the policy.
Public property Parent Gets or sets the PolicyStore that is the parent of the policy object.
Public property PolicyCategory Gets or sets the category that is associated with the policy.
Public property Properties Returns a collection instance properties. (Inherited from SfcInstance.)
Protected property PropertyStorageProvider Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public property RootCondition Gets or sets the name of the root condition for this policy.
Public property ScheduleUid Gets or sets the Guid that identifies the SQL Server Agent schedule that checks on the policy.
Protected property State Returns the state of the SfcInstance object. (Inherited from SfcInstance.)
Public property Urn Returns the uniform resource name of the SfcInstance object. (Inherited from SfcInstance.)

Top

Methods

  Name Description
Public method Alter Updates any Policy object property changes on the instance of SQL Server.
Protected method AlterImpl Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method CheckObjectCreated Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method CheckObjectState Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public method Create Creates management policy item.
Protected method CreateIdentityKey Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method CreateImpl Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public method Discover Discovers conditions in the ObjectSet and adds them to the ISfcDependencyDiscoveryObjectSink identified by the sink parameter. (Overrides SfcInstance.Discover(ISfcDependencyDiscoveryObjectSink).)
Public method Drop Removes the policy from the instance of SQL Server.
Protected method DropImpl Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public method Equals (Inherited from Object.)
Public method Evaluate(AdHocPolicyEvaluationMode, array<ISfcConnection[]) Evaluates the Policy object and applies policy to the data in identified by the targetConnections parameter.
Public method Evaluate(AdHocPolicyEvaluationMode, array<Object[]) Immediately executes the policy against the specified target objects by using the specified evaluation mode.
Public method Evaluate(AdHocPolicyEvaluationMode, SfcQueryExpression, array<ISfcConnection[]) Evaluates the Policy object and applies policy to the data in identified by the targetConnections parameter.
Protected method Finalize (Inherited from Object.)
Protected method GetChildCollection Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public method GetDomain Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public method GetHashCode (Inherited from Object.)
Public methodStatic member GetObjectFactory Gets the object factory for the object.
Public method GetPropertySet Returns the set of properties for the SfcInstance object. (Inherited from SfcInstance.)
Public method GetType (Inherited from Object.)
Protected method GetTypeMetadataImpl Indicates the domains that override by returning the right TypeMetadata class directly. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method InitializeUIPropertyState Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method MarkForDropImpl Returns a value that indicates the existing objects to be dropped. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method MarkRootAsConnected Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method MemberwiseClone (Inherited from Object.)
Protected method MoveImpl Indicates the new parent object to move in an instance. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method OnPropertyMetadataChanges Invoked whenever the effective value of any SfcInstance metadata is updated. (Inherited from SfcInstance.)
Protected method OnPropertyValueChanges Invoked whenever the effective value of any SfcInstance property is updated. (Inherited from SfcInstance.)
Protected method PostAlter Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method PostCreate Indicates the default implementor that creates the execution result. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method PostDrop Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method PostMove Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method PostRename Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public method ProduceConfigureScript Gets the condition of a Policy object.
Public method Refresh Refreshes the object's properties by reading them from the server. (Inherited from SfcInstance.)
Public method Rename Renames the policy.
Protected method RenameImpl Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected method ResetKey Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public method ScriptAlter Alters the script that is used to create the policy.
Public method ScriptAlterWithObjectSet Alters a previously created ISfcScript object of the Policy object.
Public method ScriptCreate Creates a script that is used to create the policy.
Public method ScriptCreateWithDependencies Creates the ISfcScript object of the Policy object.
Public method ScriptCreateWithObjectSet Creates the ISfcScript object of the ObjectSet.
Public method ScriptDrop Drops the script that is used to create the policy.
Public method ScriptDropWithObjectSet Drops the ISfcScript object of the ObjectSet.
Public method Serialize Serializes the instance to XML. (Inherited from SfcInstance.)
Public method ToString Returns a string representation of the instance Urn. (Inherited from SfcInstance.)
Protected method UpdateUIPropertyState Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public method UsesFacet Determines whether the facet identified by the parameter is contained by the Condition.
Protected method Validate() Indicates the basic child object's validation. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public method Validate(String) Validates a Policy object as specified by the mode parameter.

Top

Events

  Name Description
Public event ConnectionProcessingFinished Represents the event activated when connection processing completes.
Public event ConnectionProcessingStarted Represents the event activated when connection processing begins.
Public event PolicyEvaluationFinished Represents the event activated when policy evaluation completes.
Public event PolicyEvaluationStarted Represents the event activated when policy evaluation begins.
Protected event propertyChanged Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public event PropertyChanged CLS-compliant event for property changes. (Inherited from SfcInstance.)
Protected event propertyMetadataChanged Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public event PropertyMetadataChanged CLS-compliant event for property metadata changes. (Inherited from SfcInstance.)
Public event TargetProcessed Represents the event activated when policy target is processed.

Top

Fields

  Name Description
Public fieldStatic member HelpLinkStringMaxLength Specifies the maximum length of the link to help text.
Public fieldStatic member HelpTextStringMaxLength Specifies the maximum length of the help text.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method ISfcRenamable.Rename Renames the instance of Policy identified by the key parameter.
Explicit interface implemetationPrivate method ISfcRenamable.ScriptRename Renames a script in the policy.
Explicit interface implemetationPrivate method ISfcValidate.Validate Validates a Policy object.

Top

Remarks

A policy represents the relationship between an individual object or a target set of objects and a condition.

A target is an entity on an instance of SQL Server. It could be the instance of SQL Server, or a component of it, such as a database or a table.

A condition is a relationship between a facet and a Boolean expression that determine the state of the facet. A facet is a dimension of a target. For example, the target could be an instance of SQL Server, the facet is Database Mail, the expression specifies that it is installed on the instance and the condition is that Database Mail is installed. Thus, the policy is that Database Mail is installed on the specified instance of SQL Server.

The evaluation mode of the policy determines how and when the policy is checked and enforced.

Using the Policy object, you can manage the following characteristics of a policy:

  • Condition

  • Evaluation mode

  • Schedule

  • Target set filter using XPath expression

  • A job on evaluation success

  • A job on evaluation failure

  • A policy group

Examples

C#

Policy p = new Policy(ps, policyName);
p.AutomatedPolicyEvaluationMode = execMode;
p.Condition = condition.Name;
p.ScheduleUid = schedule.ScheduleUid;
if (execMode != AutomatedPolicyEvaluationMode.None) p.Enabled = true;
p.Create();

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.