NetCodeGroup クラスとは? わかりやすく解説

NetCodeGroup クラス

アセンブリダウンロード元のサイトWeb アクセス許可与えます。このクラス継承できません。

名前空間: System.Security.Policy
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class
 NetCodeGroup
    Inherits CodeGroup
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public sealed class NetCodeGroup : CodeGroup
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class NetCodeGroup sealed : public
 CodeGroup
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class NetCodeGroup extends CodeGroup
SerializableAttribute 
ComVisibleAttribute(true) 
public final class NetCodeGroup extends
 CodeGroup
解説解説

コード グループは、コード アクセス セキュリティ ポリシービルド ブロックです。各ポリシー レベルは、ルート コード グループ構成され1 つ上のコード グループ含めることができます。各子コード グループは、独自の子コード グループを持つことができます。この動作任意のレベル数まで拡張でき、ツリー形成します。各コード グループには、特定のアセンブリ証拠基づいて、そのアセンブリがそのコード グループ所属しているかどうか判断するメンバシップ条件ありますメンバシップ条件特定のアセンブリ一致したコード グループその子コード グループだけにアクセス セキュリティ ポリシー適用されます。

NetCodeGroupマージ セマンティクスは、UnionCodeGroup のセマンティクスと同じです。このクラスは、一致している子コード グループの PolicyStatement オブジェクトと、入力として受け取った Url 証拠から生成した PolicyStatement との和集合形成します。ただし、NetCodeGroup は、コード実行されているサイト接続アクセス与える、動的に計算された WebPermission を含むアクセス許可返します一方UnionCodeGroup は、静的アクセス許可セットだけを返します

NetCodeGroup作成される場合は、次の表に示す既定接続アクセス規則含まれます。

元のサイトへの接続時にコード使用することを許可されスキームおよびポート制御するには、適切な Scheme および Port プロパティ値を指定して CodeConnectAccess オブジェクトを AddConnectAccess メソッド渡します。元のスキーム証拠存在しない場合または認識されない場合適用する接続アクセス規則は、AbsentOriginScheme ("") をスキームとして指定することによって作成できますまた、AnyOtherOriginScheme ("*") をスキームとして指定して一致するスキームを持つ接続アクセス規則がないときに適用する接続アクセス規則作成することもできます

使用例使用例

NetCodeGroup作成しHTTP スキーム使用してダウンロードされたコード用に CodeConnectAccess オブジェクト追加するコード例次に示します

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();
}
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()
 throws ApplicationException
{
    final 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.get_Current();
        if (level.get_Label().Equals(userPolicyLevel)) {
            break;
        }
    }
    if (!(level.get_Label().Equals(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.set_Name("ContosoHttpCodeGroup");
    codeGroup.set_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.get_RootCodeGroup().AddChild(codeGroup);
    // Save the changes to the policy level.
    System.Security.SecurityManager.SavePolicy();
} //SetNetCodeGroupAccess
継承階層継承階層
System.Object
   System.Security.Policy.CodeGroup
    System.Security.Policy.NetCodeGroup
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からNetCodeGroup クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からNetCodeGroup クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からNetCodeGroup クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「NetCodeGroup クラス」の関連用語

NetCodeGroup クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



NetCodeGroup クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS