Policy Class

 

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

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

System.Object
  Microsoft.SqlServer.Management.Sdk.Sfc.SfcInstance
    Microsoft.SqlServer.Management.Dmf.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

NameDescription
System_CAPS_pubmethodPolicy()

Initializes a new instance of the Policy class.

System_CAPS_pubmethodPolicy(PolicyStore, String)

Initializes a new instance of the Policy class.

NameDescription
System_CAPS_protpropertyAbstractIdentityKey

Do not reference this member directly in your code. It supports the SQL Server infrastructure.(Inherited from SfcInstance.)

System_CAPS_pubpropertyAutomatedPolicyEvaluationMode

Gets or sets the evaluation mode.

System_CAPS_pubpropertyCategoryId

Gets the ID value that uniquely identifies the category that is associated with the policy.

System_CAPS_pubpropertyCondition

Gets or sets the condition.

System_CAPS_pubpropertyCreateDate

Gets the date and time when the policy was created.

System_CAPS_pubpropertyCreatedBy

Gets the policy store authentication credentials of the user who created the policy.

System_CAPS_pubpropertyDateModified

Gets the date and time when the policy was last modified.

System_CAPS_pubpropertyDescription

Gets or sets the textual description of the policy.

System_CAPS_pubpropertyEnabled

Gets or set the Boolean value that specifies whether the policy is enabled.

System_CAPS_pubpropertyEvaluationHistories

Gets the evaluation histories collection.

System_CAPS_pubpropertyHasScript

Gets the Boolean value that specifies whether the policy has a script.

System_CAPS_pubpropertyHelpLink

Gets or sets a URN to additional help information for the policy.

System_CAPS_pubpropertyHelpText

Gets or sets the display name for the help text.

System_CAPS_pubpropertyID

Gets the ID value that uniquely identifies the policy.

System_CAPS_pubpropertyIdentityKey

Gets the key that identifies the policy.

System_CAPS_pubpropertyIsSystemObject

Determines whether the Policy object is a Object.

System_CAPS_pubpropertyMetadata

Returns metadata about the instance and its domain.(Inherited from SfcInstance.)

System_CAPS_pubpropertyModifiedBy

Gets the policy store authentication credentials of the user who last modified the policy.

System_CAPS_pubpropertyName

Gets the name of the Policy object.

System_CAPS_pubpropertyObjectSet

Gets or sets the set of objects that are associated with the policy.

System_CAPS_pubpropertyParent

Gets or sets the PolicyStore that is the parent of the policy object.

System_CAPS_pubpropertyPolicyCategory

Gets or sets the category that is associated with the policy.

System_CAPS_pubpropertyProperties

Returns a collection instance properties.(Inherited from SfcInstance.)

System_CAPS_pubpropertyRootCondition

Gets or sets the name of the root condition for this policy.

System_CAPS_pubpropertyScheduleUid

Gets or sets the Guid that identifies the SQL Server Agent schedule that checks on the policy.

System_CAPS_protpropertyState

Returns the state of the SfcInstance object.(Inherited from SfcInstance.)

System_CAPS_pubpropertyUrn

Returns the uniform resource name of the SfcInstance object.(Inherited from SfcInstance.)

NameDescription
System_CAPS_pubmethodAlter()

Updates any Policy object property changes on the instance of SQL Server.

System_CAPS_pubmethodCreate()

Creates management policy item.

System_CAPS_protmethodCreateIdentityKey()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.(Inherited from SfcInstance.)

System_CAPS_pubmethodDiscover(ISfcDependencyDiscoveryObjectSink)

Discovers conditions in the ObjectSet and adds them to the ISfcDependencyDiscoveryObjectSink identified by the sink parameter.(Overrides SfcInstance.Discover(ISfcDependencyDiscoveryObjectSink).)

System_CAPS_pubmethodDrop()

Removes the policy from the instance of SQL Server.

System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_pubmethodEvaluate(AdHocPolicyEvaluationMode, ISfcConnection[])

Evaluates the Policy object and applies policy to the data in identified by the targetConnections parameter.

System_CAPS_pubmethodEvaluate(AdHocPolicyEvaluationMode, Object[])

Immediately executes the policy against the specified target objects by using the specified evaluation mode.

System_CAPS_pubmethodEvaluate(AdHocPolicyEvaluationMode, SfcQueryExpression, ISfcConnection[])

Evaluates the Policy object and applies policy to the data in identified by the targetConnections parameter.

System_CAPS_protmethodGetChildCollection(String)

Do not reference this member directly in your code. It supports the SQL Server infrastructure.(Inherited from SfcInstance.)

System_CAPS_pubmethodGetDomain()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.(Inherited from SfcInstance.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetObjectFactory()

Gets the object factory for the object.

System_CAPS_pubmethodGetPropertySet()

Returns the set of properties for the SfcInstance object.(Inherited from SfcInstance.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_protmethodGetTypeMetadataImpl()

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.)

System_CAPS_protmethodInitializeUIPropertyState()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.(Inherited from SfcInstance.)

System_CAPS_protmethodOnPropertyMetadataChanges(SfcPropertyMetadataChangedEventArgs)

Invoked whenever the effective value of any SfcInstance metadata is updated. (Inherited from SfcInstance.)

System_CAPS_protmethodOnPropertyValueChanges(PropertyChangedEventArgs)

Invoked whenever the effective value of any SfcInstance property is updated. (Inherited from SfcInstance.)

System_CAPS_pubmethodProduceConfigureScript(Object)

Gets the condition of a Policy object.

System_CAPS_pubmethodRefresh()

Refreshes the object's properties by reading them from the server.(Inherited from SfcInstance.)

System_CAPS_pubmethodRename(String)

Renames the policy.

System_CAPS_protmethodResetKey()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.(Inherited from SfcInstance.)

System_CAPS_pubmethodScriptAlter()

Alters the script that is used to create the policy.

System_CAPS_pubmethodScriptAlterWithObjectSet()

Alters a previously created ISfcScript object of the Policy object.

System_CAPS_pubmethodScriptCreate()

Creates a script that is used to create the policy.

System_CAPS_pubmethodScriptCreateWithDependencies()

Creates the ISfcScript object of the Policy object.

System_CAPS_pubmethodScriptCreateWithObjectSet()

Creates the ISfcScript object of the ObjectSet.

System_CAPS_pubmethodScriptDrop()

Drops the script that is used to create the policy.

System_CAPS_pubmethodScriptDropWithObjectSet()

Drops the ISfcScript object of the ObjectSet.

System_CAPS_pubmethodSerialize(XmlWriter)

Serializes the instance to XML.(Inherited from SfcInstance.)

System_CAPS_pubmethodToString()

Returns a string representation of the instance Urn.(Inherited from SfcInstance.)

System_CAPS_pubmethodUsesFacet(String)

Determines whether the facet identified by the parameter is contained by the Condition.

System_CAPS_pubmethodValidate(String)

Validates a Policy object as specified by the mode parameter.

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticHelpLinkStringMaxLength

Specifies the maximum length of the link to help text.

System_CAPS_pubfieldSystem_CAPS_staticHelpTextStringMaxLength

Specifies the maximum length of the help text.

NameDescription
System_CAPS_pubeventConnectionProcessingFinished

Represents the event activated when connection processing completes.

System_CAPS_pubeventConnectionProcessingStarted

Represents the event activated when connection processing begins.

System_CAPS_pubeventPolicyEvaluationFinished

Represents the event activated when policy evaluation completes.

System_CAPS_pubeventPolicyEvaluationStarted

Represents the event activated when policy evaluation begins.

System_CAPS_pubeventPropertyChanged

Occurs when a property value changes.(Inherited from SfcInstance.)

System_CAPS_pubeventPropertyMetadataChanged

Occurs when the metadata for a property has changed.(Inherited from SfcInstance.)

System_CAPS_pubeventTargetProcessed

Represents the event activated when policy target is processed.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodISfcRenamable.Rename(SfcKey)

Renames the instance of Policy identified by the key parameter.

System_CAPS_pubinterfaceSystem_CAPS_privmethodISfcRenamable.ScriptRename(SfcKey)

Renames a script in the policy.

System_CAPS_pubinterfaceSystem_CAPS_privmethodISfcValidate.Validate(String, Object[])

Validates a Policy object.

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.

Return to top
Show: