Policy Policy Policy Class

Definition

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

public ref class Policy sealed : Microsoft::SqlServer::Management::Sdk::Sfc::SfcInstance, Microsoft::SqlServer::Management::Common::IAlterable, Microsoft::SqlServer::Management::Common::ICreatable, Microsoft::SqlServer::Management::Common::IDroppable, Microsoft::SqlServer::Management::Common::IRenamable, Microsoft::SqlServer::Management::Sdk::Sfc::ISfcAlterable, Microsoft::SqlServer::Management::Sdk::Sfc::ISfcCreatable, Microsoft::SqlServer::Management::Sdk::Sfc::ISfcDroppable, Microsoft::SqlServer::Management::Sdk::Sfc::ISfcRenamable, Microsoft::SqlServer::Management::Sdk::Sfc::ISfcValidate
public sealed class Policy : Microsoft.SqlServer.Management.Sdk.Sfc.SfcInstance, Microsoft.SqlServer.Management.Common.IAlterable, Microsoft.SqlServer.Management.Common.ICreatable, Microsoft.SqlServer.Management.Common.IDroppable, Microsoft.SqlServer.Management.Common.IRenamable, Microsoft.SqlServer.Management.Sdk.Sfc.ISfcAlterable, Microsoft.SqlServer.Management.Sdk.Sfc.ISfcCreatable, Microsoft.SqlServer.Management.Sdk.Sfc.ISfcDroppable, Microsoft.SqlServer.Management.Sdk.Sfc.ISfcRenamable, Microsoft.SqlServer.Management.Sdk.Sfc.ISfcValidate
Public NotInheritable Class Policy
Inherits SfcInstance
Implements IAlterable, ICreatable, IDroppable, IRenamable, ISfcAlterable, ISfcCreatable, ISfcDroppable, ISfcRenamable, ISfcValidate
Inheritance
Implements
Microsoft.SqlServer.Management.Common.IAlterableMicrosoft.SqlServer.Management.Common.IAlterableMicrosoft.SqlServer.Management.Common.IAlterable Microsoft.SqlServer.Management.Common.ICreatableMicrosoft.SqlServer.Management.Common.ICreatableMicrosoft.SqlServer.Management.Common.ICreatable Microsoft.SqlServer.Management.Common.IDroppableMicrosoft.SqlServer.Management.Common.IDroppableMicrosoft.SqlServer.Management.Common.IDroppable Microsoft.SqlServer.Management.Common.IRenamableMicrosoft.SqlServer.Management.Common.IRenamableMicrosoft.SqlServer.Management.Common.IRenamable ISfcAlterableISfcAlterableISfcAlterable ISfcCreatableISfcCreatableISfcCreatable ISfcDroppableISfcDroppableISfcDroppable ISfcRenamableISfcRenamableISfcRenamable ISfcValidateISfcValidateISfcValidate

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

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

Constructors

Policy() Policy() Policy()

Initializes a new instance of the Policy class.

Policy(PolicyStore, String) Policy(PolicyStore, String) Policy(PolicyStore, String)

Initializes a new instance of the Policy class.

Fields

HelpLinkStringMaxLength HelpLinkStringMaxLength HelpLinkStringMaxLength

Specifies the maximum length of the link to help text.

HelpTextStringMaxLength HelpTextStringMaxLength HelpTextStringMaxLength

Specifies the maximum length of the help text.

Properties

AbstractIdentityKey AbstractIdentityKey AbstractIdentityKey

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
AutomatedPolicyEvaluationMode AutomatedPolicyEvaluationMode AutomatedPolicyEvaluationMode

Gets or sets the evaluation mode.

CategoryId CategoryId CategoryId

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

Condition Condition Condition

Gets or sets the condition.

CreateDate CreateDate CreateDate

Gets the date and time when the policy was created.

CreatedBy CreatedBy CreatedBy

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

DateModified DateModified DateModified

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

Description Description Description

Gets or sets the textual description of the policy.

Enabled Enabled Enabled

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

EvaluationHistories EvaluationHistories EvaluationHistories

Gets the evaluation histories collection.

HasScript HasScript HasScript

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

HelpLink HelpLink HelpLink

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

HelpText HelpText HelpText

Gets or sets the display name for the help text.

ID ID ID

Gets the ID value that uniquely identifies the policy.

IdentityKey IdentityKey IdentityKey

Gets the key that identifies the policy.

IsSystemObject IsSystemObject IsSystemObject

Determines whether the Policy object is a Object.

Metadata Metadata Metadata

Returns metadata about the instance and its domain.

(Inherited from SfcInstance)
ModifiedBy ModifiedBy ModifiedBy

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

Name Name Name

Gets the name of the Policy object.

ObjectSet ObjectSet ObjectSet

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

Parent Parent Parent

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

PolicyCategory PolicyCategory PolicyCategory

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

Properties Properties Properties

Returns a collection instance properties.

(Inherited from SfcInstance)
PropertyStorageProvider PropertyStorageProvider PropertyStorageProvider

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
RootCondition RootCondition RootCondition

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

ScheduleUid ScheduleUid ScheduleUid

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

State State State

Returns the state of the SfcInstance object.

(Inherited from SfcInstance)
Urn Urn Urn

Returns the uniform resource name of the SfcInstance object.

(Inherited from SfcInstance)

Methods

Alter() Alter() Alter()

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

AlterImpl() AlterImpl() AlterImpl()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
CheckObjectCreated() CheckObjectCreated() CheckObjectCreated()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
CheckObjectState() CheckObjectState() CheckObjectState()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
Create() Create() Create()

Creates management policy item.

CreateIdentityKey() CreateIdentityKey() CreateIdentityKey()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
CreateImpl() CreateImpl() CreateImpl()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
Discover(ISfcDependencyDiscoveryObjectSink) Discover(ISfcDependencyDiscoveryObjectSink) Discover(ISfcDependencyDiscoveryObjectSink)

Discovers conditions in the ObjectSet and adds them to the ISfcDependencyDiscoveryObjectSink identified by the sink parameter.

Drop() Drop() Drop()

Removes the policy from the instance of SQL Server.

DropImpl() DropImpl() DropImpl()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
Evaluate(AdHocPolicyEvaluationMode, ISfcConnection[]) Evaluate(AdHocPolicyEvaluationMode, ISfcConnection[]) Evaluate(AdHocPolicyEvaluationMode, ISfcConnection[])

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

Evaluate(AdHocPolicyEvaluationMode, Object[]) Evaluate(AdHocPolicyEvaluationMode, Object[]) Evaluate(AdHocPolicyEvaluationMode, Object[])

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

Evaluate(AdHocPolicyEvaluationMode, SfcQueryExpression, ISfcConnection[]) Evaluate(AdHocPolicyEvaluationMode, SfcQueryExpression, ISfcConnection[]) Evaluate(AdHocPolicyEvaluationMode, SfcQueryExpression, ISfcConnection[])

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

GetChildCollection(String) GetChildCollection(String) GetChildCollection(String)

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
GetDomain() GetDomain() GetDomain()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
GetObjectFactory() GetObjectFactory() GetObjectFactory()

Gets the object factory for the object.

GetPropertySet() GetPropertySet() GetPropertySet()

Returns the set of properties for the SfcInstance object.

(Inherited from SfcInstance)
GetTypeMetadataImpl() GetTypeMetadataImpl() 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)
InitializeUIPropertyState() InitializeUIPropertyState() InitializeUIPropertyState()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
MarkForDropImpl(Boolean) MarkForDropImpl(Boolean) MarkForDropImpl(Boolean)

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

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
MoveImpl(SfcInstance) MoveImpl(SfcInstance) MoveImpl(SfcInstance)

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)
OnPropertyMetadataChanges(SfcPropertyMetadataChangedEventArgs) OnPropertyMetadataChanges(SfcPropertyMetadataChangedEventArgs) OnPropertyMetadataChanges(SfcPropertyMetadataChangedEventArgs)

Invoked whenever the effective value of any SfcInstance metadata is updated.

(Inherited from SfcInstance)
OnPropertyValueChanges(PropertyChangedEventArgs) OnPropertyValueChanges(PropertyChangedEventArgs) OnPropertyValueChanges(PropertyChangedEventArgs)

Invoked whenever the effective value of any SfcInstance property is updated.

(Inherited from SfcInstance)
PostAlter(Object) PostAlter(Object) PostAlter(Object)

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
PostCreate(Object) PostCreate(Object) PostCreate(Object)

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)
PostDrop(Object) PostDrop(Object) PostDrop(Object)

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
PostMove(Object) PostMove(Object) PostMove(Object)

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
PostRename(Object) PostRename(Object) PostRename(Object)

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
ProduceConfigureScript(Object) ProduceConfigureScript(Object) ProduceConfigureScript(Object)

Gets the condition of a Policy object.

Refresh() Refresh() Refresh()

Refreshes the object's properties by reading them from the server.

(Inherited from SfcInstance)
Rename(String) Rename(String) Rename(String)

Renames the policy.

RenameImpl(SfcKey) RenameImpl(SfcKey) RenameImpl(SfcKey)

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
ResetKey() ResetKey() ResetKey()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
ScriptAlter() ScriptAlter() ScriptAlter()

Alters the script that is used to create the policy.

ScriptAlterWithObjectSet() ScriptAlterWithObjectSet() ScriptAlterWithObjectSet()

Alters a previously created ISfcScript object of the Policy object.

ScriptCreate() ScriptCreate() ScriptCreate()

Creates a script that is used to create the policy.

ScriptCreateWithDependencies() ScriptCreateWithDependencies() ScriptCreateWithDependencies()

Creates the ISfcScript object of the Policy object.

ScriptCreateWithObjectSet() ScriptCreateWithObjectSet() ScriptCreateWithObjectSet()

Creates the ISfcScript object of the ObjectSet.

ScriptDrop() ScriptDrop() ScriptDrop()

Drops the script that is used to create the policy.

ScriptDropWithObjectSet() ScriptDropWithObjectSet() ScriptDropWithObjectSet()

Drops the ISfcScript object of the ObjectSet.

Serialize(XmlWriter) Serialize(XmlWriter) Serialize(XmlWriter)

Serializes the instance to XML.

(Inherited from SfcInstance)
ToString() ToString() ToString()

Returns a string representation of the instance Urn.

(Inherited from SfcInstance)
UpdateUIPropertyState() UpdateUIPropertyState() UpdateUIPropertyState()

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
UsesFacet(String) UsesFacet(String) UsesFacet(String)

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

Validate() Validate() 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)
Validate(String) Validate(String) Validate(String)

Validates a Policy object as specified by the mode parameter.

Events

ConnectionProcessingFinished ConnectionProcessingFinished ConnectionProcessingFinished

Represents the event activated when connection processing completes.

ConnectionProcessingStarted ConnectionProcessingStarted ConnectionProcessingStarted

Represents the event activated when connection processing begins.

PolicyEvaluationFinished PolicyEvaluationFinished PolicyEvaluationFinished

Represents the event activated when policy evaluation completes.

PolicyEvaluationStarted PolicyEvaluationStarted PolicyEvaluationStarted

Represents the event activated when policy evaluation begins.

propertyChanged propertyChanged propertyChanged

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

(Inherited from SfcInstance)
PropertyChanged PropertyChanged PropertyChanged

Occurs when a property value changes.

(Inherited from SfcInstance)
propertyMetadataChanged propertyMetadataChanged propertyMetadataChanged

Do not reference this member directly in your code. It supports the SQL Server infrastructure.

Occurs when a property metadata value changes.

(Inherited from SfcInstance)
PropertyMetadataChanged PropertyMetadataChanged PropertyMetadataChanged

Occurs when the metadata for a property has changed.

(Inherited from SfcInstance)
TargetProcessed TargetProcessed TargetProcessed

Represents the event activated when policy target is processed.

Explicit Interface Implementations

ISfcRenamable.Rename(SfcKey) ISfcRenamable.Rename(SfcKey) ISfcRenamable.Rename(SfcKey)

Renames the instance of Policy identified by the key parameter.

ISfcRenamable.ScriptRename(SfcKey) ISfcRenamable.ScriptRename(SfcKey) ISfcRenamable.ScriptRename(SfcKey)

Renames a script in the policy.

ISfcValidate.Validate(String, Object[]) ISfcValidate.Validate(String, Object[]) ISfcValidate.Validate(String, Object[])

Validates a Policy object.

Applies to