PolicyStatement Constructors

Definition

Initializes a new instance of the PolicyStatement class.

Overloads

PolicyStatement(PermissionSet)

Initializes a new instance of the PolicyStatement class with the specified PermissionSet.

PolicyStatement(PermissionSet, PolicyStatementAttribute)

Initializes a new instance of the PolicyStatement class with the specified PermissionSet and attributes.

PolicyStatement(PermissionSet)

Initializes a new instance of the PolicyStatement class with the specified PermissionSet.

public:
 PolicyStatement(System::Security::PermissionSet ^ permSet);
public PolicyStatement (System.Security.PermissionSet permSet);
new System.Security.Policy.PolicyStatement : System.Security.PermissionSet -> System.Security.Policy.PolicyStatement
Public Sub New (permSet As PermissionSet)

Parameters

permSet
PermissionSet

The PermissionSet with which to initialize the new instance.

Examples

The following code example shows the use of the PolicyStatement constructor. This code example is part of a larger example provided for the PolicyStatement class.

PermissionSet^ permissions = gcnew PermissionSet(
   PermissionState::Unrestricted );
permissions->AddPermission( gcnew SecurityPermission(
   SecurityPermissionFlag::Execution ) );
permissions->AddPermission( gcnew ZoneIdentityPermission(
   SecurityZone::MyComputer ) );

// Create a policy statement based on the newly created permission
// set.
PolicyStatement^ policyStatement = gcnew PolicyStatement(
   permissions );
PermissionSet permissions 
    = new PermissionSet(PermissionState.Unrestricted);
permissions.AddPermission(
    new SecurityPermission(SecurityPermissionFlag.Execution));
permissions.AddPermission(
    new ZoneIdentityPermission(SecurityZone.MyComputer));

// Create a policy statement based on the newly created permission
// set.
PolicyStatement policyStatement = new PolicyStatement(permissions);
Dim permissions As New PermissionSet(PermissionState.Unrestricted)

permissions.AddPermission( _
    New SecurityPermission(SecurityPermissionFlag.Execution))
permissions.AddPermission( _
    New ZoneIdentityPermission(SecurityZone.MyComputer))

' Instantiate a new policy statement with specified permission set.
Dim policyStatement As New PolicyStatement(permissions)

PolicyStatement(PermissionSet, PolicyStatementAttribute)

Initializes a new instance of the PolicyStatement class with the specified PermissionSet and attributes.

public:
 PolicyStatement(System::Security::PermissionSet ^ permSet, System::Security::Policy::PolicyStatementAttribute attributes);
public PolicyStatement (System.Security.PermissionSet permSet, System.Security.Policy.PolicyStatementAttribute attributes);
new System.Security.Policy.PolicyStatement : System.Security.PermissionSet * System.Security.Policy.PolicyStatementAttribute -> System.Security.Policy.PolicyStatement
Public Sub New (permSet As PermissionSet, attributes As PolicyStatementAttribute)

Parameters

permSet
PermissionSet

The PermissionSet with which to initialize the new instance.

attributes
PolicyStatementAttribute

A bitwise combination of the PolicyStatementAttribute values.

Examples

The following code example shows the use of the PolicyStatement constructor. This code example is part of a larger example provided for the PolicyStatement class.

PermissionSet^ permissions = gcnew PermissionSet(
   PermissionState::Unrestricted );
permissions->AddPermission( gcnew SecurityPermission(
   SecurityPermissionFlag::Execution ) );
permissions->AddPermission( gcnew ZoneIdentityPermission(
   SecurityZone::MyComputer ) );

PolicyStatementAttribute levelFinalAttribute =
   PolicyStatementAttribute::LevelFinal;

// Create a new policy statement with the specified permission set.
// The LevelFinal attribute is set to prevent the evaluation of lower
// policy levels in a resolve operation.
PolicyStatement^ policyStatement = gcnew PolicyStatement(
   permissions,levelFinalAttribute );
PermissionSet permissions =
    new PermissionSet(PermissionState.Unrestricted);
permissions.AddPermission(
    new SecurityPermission(SecurityPermissionFlag.Execution));
permissions.AddPermission(
    new ZoneIdentityPermission(SecurityZone.MyComputer));

PolicyStatementAttribute levelFinalAttribute = 
    PolicyStatementAttribute.LevelFinal;

// Create a new policy statement with the specified permission set.
// The LevelFinal attribute is set to prevent the evaluation of lower
// policy levels in a resolve operation.
PolicyStatement policyStatement =
    new PolicyStatement(permissions, levelFinalAttribute);
Dim permissions As New PermissionSet(PermissionState.Unrestricted)
permissions.AddPermission( _
    New SecurityPermission(SecurityPermissionFlag.Execution))
permissions.AddPermission( _
    New ZoneIdentityPermission(SecurityZone.MyComputer))

Dim levelFinalAttribute As PolicyStatementAttribute
levelFinalAttribute = PolicyStatementAttribute.LevelFinal

' Instantiate a new policy statement with specified permission set
' and the LevelFinal attibute set allowing lower policy levels to be
' avoided in a resolve.
Dim policyStatement As _
    New PolicyStatement(permissions, levelFinalAttribute)

Applies to