Export (0) Print
Expand All

Policy Class

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

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)

[StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
[StrongNameIdentityPermissionAttribute(SecurityAction.LinkDemand, PublicKey = "0024000004800000940000000602000000240000525341310004000001000100272736ad6e5f9586bac2d531eabc3acc666c2f8ec879fa94f8f7b0327d2ff2ed523448f83c3d5c5dd2dfc7bc99c5286b2c125117bf5cbe242b9d41750732b2bdffe649c6efb8e5526d526fdd130095ecdb7bf210809c6cdad8824faa9ac0310ac3cba2aa0523567b2dfa7fe250b30facbd62d4ec99b94ac47c7d3b28f1f6e4c8")]
public sealed class Policy : SfcInstance, 
	ISfcCreatable, ICreatable, ISfcDroppable, IDroppable, ISfcAlterable, 
	IAlterable, ISfcRenamable, IRenamable, ISfcValidate

The Policy type exposes the following members.

  NameDescription
Public methodPolicy()Initializes a new instance of the Policy class.
Public methodPolicy(PolicyStore, String)Initializes a new instance of the Policy class.
Top

  NameDescription
Protected propertyAbstractIdentityKeyDo not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public propertyAutomatedPolicyEvaluationModeGets or sets the evaluation mode.
Public propertyCategoryIdGets the ID value that uniquely identifies the category that is associated with the policy.
Public propertyConditionGets or sets the condition.
Public propertyCreateDateGets the date and time when the policy was created.
Public propertyCreatedByGets the policy store authentication credentials of the user who created the policy.
Public propertyDateModifiedGets the date and time when the policy was last modified.
Public propertyDescriptionGets or sets the textual description of the policy.
Public propertyEnabledGets or set the Boolean value that specifies whether the policy is enabled.
Public propertyEvaluationHistoriesGets the evaluation histories collection.
Public propertyHasScriptGets the Boolean value that specifies whether the policy has a script.
Public propertyHelpLinkGets or sets a URN to additional help information for the policy.
Public propertyHelpTextGets or sets the display name for the help text.
Public propertyIDGets the ID value that uniquely identifies the policy.
Public propertyIdentityKeyGets the key that identifies the policy.
Public propertyIsSystemObjectDetermines whether the Policy object is a Object.
Public propertyMetadataReturns metadata about the instance and its domain. (Inherited from SfcInstance.)
Public propertyModifiedByGets the policy store authentication credentials of the user who last modified the policy.
Public propertyNameGets the name of the Policy object.
Public propertyObjectSetGets or sets the set of objects that are associated with the policy.
Public propertyParentGets or sets the PolicyStore that is the parent of the policy object.
Public propertyPolicyCategoryGets or sets the category that is associated with the policy.
Public propertyPropertiesReturns a collection instance properties. (Inherited from SfcInstance.)
Public propertyRootConditionGets or sets the name of the root condition for this policy.
Public propertyScheduleUidGets or sets the Guid that identifies the SQL Server Agent schedule that checks on the policy.
Protected propertyStateReturns the state of the SfcInstance object. (Inherited from SfcInstance.)
Public propertyUrnReturns the uniform resource name of the SfcInstance object. (Inherited from SfcInstance.)
Top

  NameDescription
Public methodAlterUpdates any Policy object property changes on the instance of SQL Server.
Public methodCreateCreates management policy item.
Protected methodCreateIdentityKeyDo not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public methodDiscoverDiscovers conditions in the ObjectSet and adds them to the ISfcDependencyDiscoveryObjectSink identified by the sink parameter. (Overrides SfcInstance.Discover(ISfcDependencyDiscoveryObjectSink).)
Public methodDropRemoves the policy from the instance of SQL Server.
Public methodEquals (Inherited from Object.)
Public methodEvaluate(AdHocPolicyEvaluationMode, ISfcConnection[])Evaluates the Policy object and applies policy to the data in identified by the targetConnections parameter.
Public methodEvaluate(AdHocPolicyEvaluationMode, Object[])Immediately executes the policy against the specified target objects by using the specified evaluation mode.
Public methodEvaluate(AdHocPolicyEvaluationMode, SfcQueryExpression, ISfcConnection[])Evaluates the Policy object and applies policy to the data in identified by the targetConnections parameter.
Protected methodGetChildCollectionDo not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public methodGetDomainDo not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public methodGetHashCode (Inherited from Object.)
Public methodStatic memberGetObjectFactoryGets the object factory for the object.
Public methodGetPropertySetReturns the set of properties for the SfcInstance object. (Inherited from SfcInstance.)
Public methodGetType (Inherited from Object.)
Protected methodGetTypeMetadataImplIndicates 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 methodInitializeUIPropertyStateDo not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Protected methodOnPropertyMetadataChangesInvoked whenever the effective value of any SfcInstance metadata is updated. (Inherited from SfcInstance.)
Protected methodOnPropertyValueChangesInvoked whenever the effective value of any SfcInstance property is updated. (Inherited from SfcInstance.)
Public methodProduceConfigureScriptGets the condition of a Policy object.
Public methodRefreshRefreshes the object's properties by reading them from the server. (Inherited from SfcInstance.)
Public methodRenameRenames the policy.
Protected methodResetKeyDo not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SfcInstance.)
Public methodScriptAlterAlters the script that is used to create the policy.
Public methodScriptAlterWithObjectSetAlters a previously created ISfcScript object of the Policy object.
Public methodScriptCreateCreates a script that is used to create the policy.
Public methodScriptCreateWithDependenciesCreates the ISfcScript object of the Policy object.
Public methodScriptCreateWithObjectSetCreates the ISfcScript object of the ObjectSet.
Public methodScriptDropDrops the script that is used to create the policy.
Public methodScriptDropWithObjectSetDrops the ISfcScript object of the ObjectSet.
Public methodSerializeSerializes the instance to XML. (Inherited from SfcInstance.)
Public methodToStringReturns a string representation of the instance Urn. (Inherited from SfcInstance.)
Public methodUsesFacetDetermines whether the facet identified by the parameter is contained by the Condition.
Public methodValidateValidates a Policy object as specified by the mode parameter.
Top

  NameDescription
Public eventConnectionProcessingFinishedRepresents the event activated when connection processing completes.
Public eventConnectionProcessingStartedRepresents the event activated when connection processing begins.
Public eventPolicyEvaluationFinishedRepresents the event activated when policy evaluation completes.
Public eventPolicyEvaluationStartedRepresents the event activated when policy evaluation begins.
Public eventPropertyChangedCLS-compliant event for property changes. (Inherited from SfcInstance.)
Public eventPropertyMetadataChangedCLS-compliant event for property metadata changes. (Inherited from SfcInstance.)
Public eventTargetProcessedRepresents the event activated when policy target is processed.
Top

  NameDescription
Public fieldStatic memberHelpLinkStringMaxLengthSpecifies the maximum length of the link to help text.
Public fieldStatic memberHelpTextStringMaxLengthSpecifies the maximum length of the help text.
Top

  NameDescription
Explicit interface implemetationPrivate methodISfcRenamable.RenameRenames the instance of Policy identified by the key parameter.
Explicit interface implemetationPrivate methodISfcRenamable.ScriptRenameRenames a script in the policy.
Explicit interface implemetationPrivate methodISfcValidate.ValidateValidates a Policy object.
Top

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

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();

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft