다음을 통해 공유


PolicyLevelType 열거형

관리 코드 정책 수준의 형식을 지정합니다.

네임스페이스: System.Security
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration PolicyLevelType
‘사용 방법
Dim instance As PolicyLevelType
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public enum PolicyLevelType
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public enum class PolicyLevelType
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum PolicyLevelType
SerializableAttribute 
ComVisibleAttribute(true) 
public enum PolicyLevelType

멤버

  멤버 이름 설명
AppDomain 응용 프로그램에 있는 모든 관리 코드에 대한 보안 정책입니다. 
Enterprise 엔터프라이즈 내에 있는 모든 관리 코드에 대한 보안 정책입니다. 
Machine 컴퓨터에서 실행되는 모든 관리 코드에 대한 보안 정책입니다. 
User 사용자가 실행하는 모든 관리 코드에 대한 보안 정책입니다. 

설명

최상위 수준의 보안 정책은 엔터프라이즈 수준입니다. 하위 수준에 정책 제한 사항을 세부적으로 지정할 수 있지만 상위 수준에서 허용하는 것 이상의 사용 권한을 부여하지는 못합니다. 정책 수준 순서는 다음과 같습니다.

1. 엔터프라이즈

2. 컴퓨터

3. 사용자

4. 응용 프로그램 도메인

예제

이 예제에서는 PolicyLevelType 열거형을 사용하여 코드 액세스 보안 관리 설정 정보를 쿼리하는 방법을 보여 줍니다.

using System;
using System.Collections;
using System.Security;
using System.Security.Policy;

public sealed class App
{
    static void Main()
    {
        DisplayIntranetZonePermissionSetForPolicyLevel(PolicyLevelType.User);
        Console.WriteLine();
        DisplayIntranetZonePermissionSetForPolicyLevel(PolicyLevelType.Machine);
    }

   static void DisplayIntranetZonePermissionSetForPolicyLevel(PolicyLevelType policyLevelType)
   {
        // Create an Evidence object that contains the intranet zone.
        Evidence e = new Evidence();
        e.AddHost(new Zone(SecurityZone.Intranet));
        // Get the policy level for the specified policy level type and then
        // resolve the evidence against it to get the policy statement.
        PolicyStatement ps = GetPolicyLevel(policyLevelType).Resolve(e);

        // Show the calculated policy statement.
        Console.WriteLine("---> Intranet zone permission set for {0} policy level:", policyLevelType.ToString());
        Console.WriteLine(ps.PermissionSet);
    }

    // This helper method returns a PolicyLevel that corresponds to the specified PolicyLevelType.
    static PolicyLevel GetPolicyLevel(PolicyLevelType policyLevelType)
    {
        IEnumerator policyLevels = SecurityManager.PolicyHierarchy();

        // Map the policy level type to the policy level collection.
        int levelCnt = 0;
        switch (policyLevelType)
        {
            case PolicyLevelType.Enterprise: levelCnt = 0; break;
            case PolicyLevelType.Machine: levelCnt = 1; break;
            case PolicyLevelType.User: levelCnt = 2; break;
            case PolicyLevelType.AppDomain: levelCnt = 3; break;
        }

        for (; levelCnt >= 0; levelCnt--) policyLevels.MoveNext();
        return (PolicyLevel) policyLevels.Current;
   }
}

// This code produces the following output.
//
// ---> Intranet Zone permission set for User policy level:
// <PermissionSet class="System.Security.PermissionSet"
// version="1"
// Unrestricted="true"/>
// ---> Intranet Zone permission set for Machine policy level:
// <PermissionSet class="System.Security.PermissionSet"
// version="1">
// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, // Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Read="USERNAME"/>
// <IPermission class="System.Security.Permissions.FileDialogPermission, mscorlib, // Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Unrestricted="true"/>
// <IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib,// Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Allowed="AssemblyIsolationByUser"
// UserQuota="9223372036854775807"
// Expiry="9223372036854775807"
// Permanent="True"/>
// <IPermission class="System.Security.Permissions.ReflectionPermission, mscorlib,
// Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Flags="ReflectionEmit"/>
// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib,
// Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Flags="Assertion, Execution, BindingRedirects"/>
// <IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.3600.0, // Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Unrestricted="true"/>
// <IPermission class="System.Net.DnsPermission, System, Version=2.0.3600.0, Culture=neutral, // PublicKeyToken=b77a5c561934e089"
// version="1"
// Unrestricted="true"/>
// <IPermission class="System.Windows.Forms.WebBrowserPermission, System, Version=2.0.3600.0, // Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Level="Restricted"/>
// <IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing, 
// Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
// version="1"
// Level="DefaultPrinting"/>
// <IPermission class="System.Diagnostics.EventLogPermission, System, Version=2.0.3600.0, 
// Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1">
// <Machine name="."
// access="Instrument"/>
// </IPermission>
// </PermissionSet>
using namespace System;
using namespace System::Collections;
using namespace System::Security;
using namespace System::Security::Policy;

// This helper method returns a PolicyLevel that corresponds to
// the specified PolicyLevelType.
PolicyLevel^ GetPolicyLevel(PolicyLevelType policyLevelType)
{
    IEnumerator^ policyLevels = SecurityManager::PolicyHierarchy();

    // Map the policy level type to the policy level collection.
    int levelCount = 0;
    switch (policyLevelType)
    {
    case PolicyLevelType::Enterprise: levelCount = 0; break;
    case PolicyLevelType::Machine: levelCount = 1; break;
    case PolicyLevelType::User: levelCount = 2; break;
    case PolicyLevelType::AppDomain: levelCount = 3; break;
    }

    for (; levelCount >= 0; levelCount--)
    {
        policyLevels->MoveNext();
    }

    return (PolicyLevel^) policyLevels->Current;
}

void DisplayIntranetZonePermissionSetForPolicyLevel(
    PolicyLevelType policyLevelType)
{
    // Create an Evidence object that contains the intranet zone.
    Evidence^ intranetEvidence = gcnew Evidence();
    intranetEvidence->AddHost(gcnew Zone(SecurityZone::Intranet));
    // Get the policy level for the specified policy level type and then
    // resolve the evidence against it to get the policy statement.
    PolicyStatement^ resolvedPolicy = GetPolicyLevel(policyLevelType)->
        Resolve(intranetEvidence);

    // Show the calculated policy statement.
    Console::WriteLine(
        "---> Intranet zone permission set for {0} policy level:",
        policyLevelType);
    Console::WriteLine(resolvedPolicy->PermissionSet);
}

int main()
{
    DisplayIntranetZonePermissionSetForPolicyLevel(PolicyLevelType::User);
    Console::WriteLine();
    DisplayIntranetZonePermissionSetForPolicyLevel(PolicyLevelType::Machine);
}

// This code produces the following output.
//
// ---> Intranet Zone permission set for User policy level:
// <PermissionSet class="System.Security.PermissionSet"
// version="1"
// Unrestricted="true"/>
// ---> Intranet Zone permission set for Machine policy level:
// <PermissionSet class="System.Security.PermissionSet"
// version="1">
// <IPermission class="System.Security.Permissions.EnvironmentPermission,
// mscorlib, 
// Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Read="USERNAME"/>
// <IPermission class="System.Security.Permissions.FileDialogPermission,
// mscorlib, 
// Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Unrestricted="true"/>
// <IPermission class=
// "System.Security.Permissions.IsolatedStorageFilePermission, mscorlib,
// Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Allowed="AssemblyIsolationByUser"
// UserQuota="9223372036854775807"
// Expiry="9223372036854775807"
// Permanent="True"/>
// <IPermission class="System.Security.Permissions.ReflectionPermission,
// mscorlib,
// Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Flags="ReflectionEmit"/>
// <IPermission class="System.Security.Permissions.SecurityPermission,
// mscorlib,
// Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Flags="Assertion, Execution, BindingRedirects"/>
// <IPermission class="System.Security.Permissions.UIPermission, mscorlib,
// Version=2.0.3600.0, 
// Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Unrestricted="true"/>
// <IPermission class="System.Net.DnsPermission, System, Version=2.0.3600.0,
// Culture=neutral, 
// PublicKeyToken=b77a5c561934e089"
// version="1"
// Unrestricted="true"/>
// <IPermission class="System.Windows.Forms.WebBrowserPermission, System,
// Version=2.0.3600.0, 
// Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1"
// Level="Restricted"/>
// <IPermission class="System.Drawing.Printing.PrintingPermission,
// System.Drawing,
// Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
// version="1"
// Level="DefaultPrinting"/>
// <IPermission class="System.Diagnostics.EventLogPermission, System,
// Version=2.0.3600.0,
// Culture=neutral, PublicKeyToken=b77a5c561934e089"
// version="1">
// <Machine name="."
// access="Instrument"/>
// </IPermission>
// </PermissionSet>

플랫폼

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

참고 항목

참조

System.Security 네임스페이스
PolicyLevel
PolicyHierarchy