CodeConnectAccess 클래스
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
코드에 부여된 네트워크 리소스 액세스를 지정합니다.
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 사용합니다.
Code |
CodeConnectAccess 클래스의 새 인스턴스를 초기화합니다. |
Any |
체계 와일드카드를 나타내는 문자열 값을 포함합니다. |
Default |
기본 포트를 나타내는 데 사용되는 값을 포함합니다. |
Origin |
원본 코드가 있는 URI의 포트 값을 나타내는 데 사용되는 값을 포함합니다. |
Origin |
원본 코드가 있는 URL의 체계를 나타내는 데 사용되는 값을 포함합니다. |
Create |
임의의 체계를 사용하여 지정된 포트에 액세스하는 것을 나타내는 CodeConnectAccess 인스턴스를 반환합니다. |
Create |
코드의 원래 체계를 사용하여 지정된 포트에 액세스하는 것을 나타내는 CodeConnectAccess 인스턴스를 반환합니다. |
Equals(Object) |
두 CodeConnectAccess 개체가 같은 체계와 포트를 나타내는지 여부를 나타내는 값을 반환합니다. |
Get |
특정 유형에 대한 해시 함수로 사용합니다. |
Get |
현재 인스턴스의 Type을 가져옵니다. (다음에서 상속됨 Object) |
Memberwise |
현재 Object의 단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
To |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
제품 | 버전 |
---|---|
.NET | 8 (package-provided), 9 (package-provided) |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |
.NET 피드백
.NET은(는) 오픈 소스 프로젝트입니다. 다음 링크를 선택하여 피드백을 제공해 주세요.