Compartilhar via


PolicyStatement Construtores

Definição

Inicializa uma nova instância da classe PolicyStatement.

Sobrecargas

PolicyStatement(PermissionSet)
Obsoleto.

Inicializa uma nova instância da classe PolicyStatement com o PermissionSet especificado.

PolicyStatement(PermissionSet, PolicyStatementAttribute)
Obsoleto.

Inicializa uma nova instância da classe PolicyStatement com o PermissionSet e os atributos especificados.

PolicyStatement(PermissionSet)

Origem:
PolicyStatement.cs
Origem:
PolicyStatement.cs
Origem:
PolicyStatement.cs
Origem:
PolicyStatement.cs

Cuidado

Code Access Security is not supported or honored by the runtime.

Inicializa uma nova instância da classe PolicyStatement com o PermissionSet especificado.

public:
 PolicyStatement(System::Security::PermissionSet ^ permSet);
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public PolicyStatement (System.Security.PermissionSet permSet);
public PolicyStatement (System.Security.PermissionSet permSet);
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Policy.PolicyStatement : System.Security.PermissionSet -> System.Security.Policy.PolicyStatement
new System.Security.Policy.PolicyStatement : System.Security.PermissionSet -> System.Security.Policy.PolicyStatement
Public Sub New (permSet As PermissionSet)

Parâmetros

permSet
PermissionSet

O PermissionSet com o qual inicializar a nova instância.

Atributos

Exemplos

O exemplo de código a seguir mostra o uso do PolicyStatement construtor . Este exemplo de código faz parte de um exemplo maior fornecido para a PolicyStatement classe .

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)

Comentários

Cuidado

O CAS (Segurança de Acesso do Código) foi preterido em todas as versões do .NET Framework e do .NET. As versões recentes do .NET não aceitam anotações de CAS e produzem erros caso as APIs relacionadas ao CAS sejam usadas. Os desenvolvedores devem buscar meios alternativos de realizar tarefas de segurança.

Aplica-se a

PolicyStatement(PermissionSet, PolicyStatementAttribute)

Origem:
PolicyStatement.cs
Origem:
PolicyStatement.cs
Origem:
PolicyStatement.cs
Origem:
PolicyStatement.cs

Cuidado

Code Access Security is not supported or honored by the runtime.

Inicializa uma nova instância da classe PolicyStatement com o PermissionSet e os atributos especificados.

public:
 PolicyStatement(System::Security::PermissionSet ^ permSet, System::Security::Policy::PolicyStatementAttribute attributes);
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public PolicyStatement (System.Security.PermissionSet permSet, System.Security.Policy.PolicyStatementAttribute attributes);
public PolicyStatement (System.Security.PermissionSet permSet, System.Security.Policy.PolicyStatementAttribute attributes);
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Policy.PolicyStatement : System.Security.PermissionSet * System.Security.Policy.PolicyStatementAttribute -> System.Security.Policy.PolicyStatement
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)

Parâmetros

permSet
PermissionSet

O PermissionSet com o qual inicializar a nova instância.

attributes
PolicyStatementAttribute

Uma combinação bit a bit dos valores PolicyStatementAttribute.

Atributos

Exemplos

O exemplo de código a seguir mostra o uso do PolicyStatement construtor . Este exemplo de código faz parte de um exemplo maior fornecido para a PolicyStatement classe .

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)

Comentários

Cuidado

O CAS (Segurança de Acesso do Código) foi preterido em todas as versões do .NET Framework e do .NET. As versões recentes do .NET não aceitam anotações de CAS e produzem erros caso as APIs relacionadas ao CAS sejam usadas. Os desenvolvedores devem buscar meios alternativos de realizar tarefas de segurança.

Aplica-se a