Share via


CodeConnectAccess 클래스

정의

코드에 부여된 네트워크 리소스 액세스를 지정합니다.

public ref class CodeConnectAccess
public class CodeConnectAccess
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class CodeConnectAccess
type CodeConnectAccess = class
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type CodeConnectAccess = class
Public Class CodeConnectAccess
상속
CodeConnectAccess
특성

예제

다음 코드 예제에서는 개체를 NetCodeGroup 만들고 사용자 정책 수준에 추가합니다.


static void SetNetCodeGroupAccess()
{
    String^ userPolicyLevel = "User";
    // Locate the User policy level.
    PolicyLevel^ level = nullptr;
    System::Collections::IEnumerator^ ph = 
        System::Security::SecurityManager::PolicyHierarchy();
    while(ph->MoveNext())
    {
        level = (PolicyLevel^)ph->Current;
        if (level->Label == userPolicyLevel)
        {
            break;       
        }
    }
    if (level->Label != userPolicyLevel)
        throw gcnew ApplicationException("Could not find User policy level.");

    IMembershipCondition^ membership =
        gcnew UrlMembershipCondition("http://www.contoso.com/*");
    NetCodeGroup^ codeGroup = gcnew NetCodeGroup(membership);
    // Delete default settings.
    codeGroup->ResetConnectAccess();
    // Create an object that represents access to the FTP scheme and 
    // default port.
    CodeConnectAccess^ CodeAccessFtp = 
        gcnew CodeConnectAccess(Uri::UriSchemeFtp, 
        CodeConnectAccess::DefaultPort);
    // Create an object that represents access to the HTTPS scheme 
    // and default port.
    CodeConnectAccess^ CodeAccessHttps = 
        gcnew CodeConnectAccess(Uri::UriSchemeHttps, 
        CodeConnectAccess::DefaultPort);
    // Create an object that represents access to the origin 
    // scheme and port.
    CodeConnectAccess^ CodeAccessOrigin = 
        CodeConnectAccess::CreateOriginSchemeAccess
        (CodeConnectAccess::OriginPort);
    // Add connection access objects to the NetCodeGroup object.
    codeGroup->AddConnectAccess(Uri::UriSchemeHttp, CodeAccessFtp);
    codeGroup->AddConnectAccess(Uri::UriSchemeHttp, CodeAccessHttps);
    codeGroup->AddConnectAccess(Uri::UriSchemeHttp, CodeAccessOrigin);
    // Provide name and description information for caspol.exe tool.
    codeGroup->Name = "ContosoHttpCodeGroup";
    codeGroup->Description = "Code originating from contoso.com can" +
        " connect back using the FTP or HTTPS.";
    // Add the code group to the User policy's root node.
    level->RootCodeGroup->AddChild(codeGroup);
    // Save the changes to the policy level.
    System::Security::SecurityManager::SavePolicy();
}
public static void SetNetCodeGroupAccess()
{
    const string userPolicyLevel = "User";
    // Locate the User policy level.
    PolicyLevel level = null;
    System.Collections.IEnumerator ph =
        System.Security.SecurityManager.PolicyHierarchy();
    while(ph.MoveNext())
    {
        level = (PolicyLevel)ph.Current;
        if( level.Label == userPolicyLevel )
        {
            break;
        }
    }
    if (level.Label != userPolicyLevel)
        throw new ApplicationException("Could not find User policy level.");

    IMembershipCondition membership =
        new UrlMembershipCondition(@"http://www.contoso.com/*");
    NetCodeGroup codeGroup = new NetCodeGroup(membership);
    // Delete default settings.
    codeGroup.ResetConnectAccess();
    // Create an object that represents access to the FTP scheme and default port.
    CodeConnectAccess a1 = new CodeConnectAccess(Uri.UriSchemeFtp, CodeConnectAccess.DefaultPort);
    // Create an object that represents access to the HTTPS scheme and default port.
    CodeConnectAccess a2 = new CodeConnectAccess(Uri.UriSchemeHttps, CodeConnectAccess.DefaultPort);
    // Create an object that represents access to the origin scheme and port.
    CodeConnectAccess a3 = CodeConnectAccess.CreateOriginSchemeAccess(CodeConnectAccess.OriginPort);
    // Add connection access objects to the NetCodeGroup object.
    codeGroup.AddConnectAccess(Uri.UriSchemeHttp, a1);
    codeGroup.AddConnectAccess(Uri.UriSchemeHttp, a2);
    codeGroup.AddConnectAccess(Uri.UriSchemeHttp, a3);
    // Provide name and description information for caspol.exe tool.
    codeGroup.Name = "ContosoHttpCodeGroup";
    codeGroup.Description = "Code originating from contoso.com can connect back using the FTP or HTTPS.";
    // Add the code group to the User policy's root node.
    level.RootCodeGroup.AddChild(codeGroup);
    // Save the changes to the policy level.
    System.Security.SecurityManager.SavePolicy();
}

설명

이 클래스는 실행 코드가 다운로드된 사이트에 다시 연결하는 방법을 제어하기 위해 클래스와 함께 NetCodeGroup 사용됩니다. 이러한 클래스는 코드가 WebPermission 원본 사이트에 액세스하는 데 사용할 수 있는 스키마 및 포트를 제어하는 실행 코드에 부여된 를 프로그래밍 방식으로 제어합니다. 코드가 시작되는 URL의 체계에 따라 허용되는 체계 및 포트 쌍을 지정할 수 있습니다.

코드의 원본 구성표에 따라 개체를 만들 CodeConnectAccess 려면 메서드를 CreateOriginSchemeAccess 사용합니다.

모든 체계를 CodeConnectAccess 사용할 수 있지만 포트로 제한되는 개체를 만들려면 메서드를 CreateAnySchemeAccess 사용합니다.

생성자

CodeConnectAccess(String, Int32)

CodeConnectAccess 클래스의 새 인스턴스를 초기화합니다.

필드

AnyScheme

체계 와일드카드를 나타내는 문자열 값을 포함합니다.

DefaultPort

기본 포트를 나타내는 데 사용되는 값을 포함합니다.

OriginPort

원본 코드가 있는 URI의 포트 값을 나타내는 데 사용되는 값을 포함합니다.

OriginScheme

원본 코드가 있는 URL의 체계를 나타내는 데 사용되는 값을 포함합니다.

속성

Port

현재 인스턴스가 나타내는 포트를 가져옵니다.

Scheme

현재 인스턴스가 나타내는 URI 체계를 가져옵니다.

메서드

CreateAnySchemeAccess(Int32)

임의의 체계를 사용하여 지정된 포트에 액세스하는 것을 나타내는 CodeConnectAccess 인스턴스를 반환합니다.

CreateOriginSchemeAccess(Int32)

코드의 원래 체계를 사용하여 지정된 포트에 액세스하는 것을 나타내는 CodeConnectAccess 인스턴스를 반환합니다.

Equals(Object)

CodeConnectAccess 개체가 같은 체계와 포트를 나타내는지 여부를 나타내는 값을 반환합니다.

GetHashCode()

특정 유형에 대한 해시 함수로 사용합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상