SecurityManager.GetStandardSandbox(Evidence) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
제공된 증명 정보가 있는 애플리케이션에 부여하는 데 안전한 권한 집합을 가져옵니다.
public:
static System::Security::PermissionSet ^ GetStandardSandbox(System::Security::Policy::Evidence ^ evidence);
public static System.Security.PermissionSet GetStandardSandbox(System.Security.Policy.Evidence evidence);
static member GetStandardSandbox : System.Security.Policy.Evidence -> System.Security.PermissionSet
Public Shared Function GetStandardSandbox (evidence As Evidence) As PermissionSet
매개 변수
- evidence
- Evidence
권한 집합에 일치시킬 호스트 증명 정보입니다.
반환
제공된 증명 정보가 있는 애플리케이션에 대한 권한 부여 설정으로 사용 가능한 권한 집합입니다.
예외
evidence이(가) null인 경우
예제
다음 예제에서는 사용 하는 방법의 GetStandardSandbox 샌드박스 애플리케이션에 대 한 사용 권한을 얻는 메서드를 설정 합니다. 샌드박스에서 애플리케이션을 실행 하는 방법에 대 한 자세한 내용은 참조 하세요. 방법: 부분적으로 신뢰할 수 있는 코드 실행 샌드박스에서합니다.
using System;
using System.Collections;
using System.Diagnostics;
using System.Security;
using System.Security.Permissions;
using System.Security.Policy;
using System.Reflection;
using System.IO;
namespace SimpleSandboxing
{
class Program
{
static void Main(string[] args)
{
// Create the permission set to grant to other assemblies.
// In this case we are granting the permissions found in the LocalIntranet zone.
Evidence e = new Evidence();
e.AddHostEvidence(new Zone(SecurityZone.Intranet));
PermissionSet pset = SecurityManager.GetStandardSandbox(e);
AppDomainSetup ads = new AppDomainSetup();
// Identify the folder to use for the sandbox.
ads.ApplicationBase = "C:\\Sandbox";
// Copy the application to be executed to the sandbox.
Directory.CreateDirectory("C:\\Sandbox");
File.Copy("..\\..\\..\\HelloWorld\\bin\\debug\\HelloWorld.exe", "C:\\sandbox\\HelloWorld.exe", true);
// Create the sandboxed domain.
AppDomain sandbox = AppDomain.CreateDomain(
"Sandboxed Domain",
e,
ads,
pset,
null);
sandbox.ExecuteAssemblyByName("HelloWorld");
}
}
}
Imports System.Collections
Imports System.Diagnostics
Imports System.Security
Imports System.Security.Permissions
Imports System.Security.Policy
Imports System.Reflection
Imports System.IO
Class Program
Shared Sub Main(ByVal args() As String)
' Create the permission set to grant to other assemblies.
' In this case we are granting the permissions found in the LocalIntranet zone.
Dim e As New Evidence()
e.AddHostEvidence(New Zone(SecurityZone.Intranet))
Dim pset As PermissionSet = SecurityManager.GetStandardSandbox(e)
Dim ads As New AppDomainSetup()
' Identify the folder to use for the sandbox.
ads.ApplicationBase = "C:\Sandbox"
' Copy the application to be executed to the sandbox.
Directory.CreateDirectory("C:\Sandbox")
File.Copy("..\..\..\HelloWorld\bin\debug\HelloWorld.exe", "C:\sandbox\HelloWorld.exe", True)
' Create the sandboxed domain.
Dim sandbox As AppDomain = AppDomain.CreateDomain("Sandboxed Domain", e, ads, pset, Nothing)
sandbox.ExecuteAssemblyByName("HelloWorld")
End Sub
End Class
설명
참고
.NET Framework 4에서 의 호스트 증거에는 evidence 증거가 포함되어 System.Security.Policy.Zone 야 합니다.
다음 표에서는 각 영역에 대해 반환되는 권한 집합을 보여 줍니다.
| 영역 | 권한 집합 |
|---|---|
| MyComputer | FullTrust |
| Intranet | LocalIntranet |
| Trusted | Internet |
| Internet | Internet |
| Untrusted | 없음 |
| NoZone | 없음 |
또는 Site와 같은 Url 다른 증거가 고려될 수 있습니다.
반환 된 권한 집합을 애플리케이션을 실행 하는 샌드박스를 통해 사용할 수 있습니다. 이 메서드가 정책을 지정 하지 않습니다 아니라 호스트 애플리케이션에서 요청한 권한 집합이 적절 한 인지 여부를 확인 하는 데는 참고 합니다. 이 메서드는 샌드박스에 영역을 매핑하는 데 사용할 수 있습니다.