NetCodeGroup クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ Public NotInheritable Class NetCodeGroup Inherits CodeGroup
[SerializableAttribute] [ComVisibleAttribute(true)] public ref class NetCodeGroup sealed : public 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.Security.Policy.CodeGroup
System.Security.Policy.NetCodeGroup


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NetCodeGroup コンストラクタ
アセンブリ: mscorlib (mscorlib.dll 内)

Dim membershipCondition As IMembershipCondition Dim instance As New NetCodeGroup(membershipCondition)


NetCodeGroup が作成される場合は、次の表に示す既定の接続アクセス規則が含まれます。
Scope プロパティが System.Security.Policy.CodeGroupGrantScope.Assembly に設定されています。

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

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NetCodeGroup フィールド

名前 | 説明 | |
---|---|---|
![]() | AbsentOriginScheme | コードの元のスキームが未知であるか、または認識されない場合にコードの接続アクセスを指定するための値を含みます。 |
![]() | AnyOtherOriginScheme | 他の指定されていない元のスキームを指定するために使用される値を含んでいます。 |

NetCodeGroup プロパティ

名前 | 説明 | |
---|---|---|
![]() | AttributeString | オーバーライドされます。 コード グループのポリシー ステートメントの属性の文字列形式を取得します。 |
![]() | Children | コード グループの子コード グループを順序付けして示したリストを取得または設定します。 ( CodeGroup から継承されます。) |
![]() | Description | コード グループの説明を取得または設定します。 ( CodeGroup から継承されます。) |
![]() | MembershipCondition | コード グループのメンバシップ条件を取得または設定します。 ( CodeGroup から継承されます。) |
![]() | MergeLogic | オーバーライドされます。 グループをマージするために使用するロジックを取得します。 |
![]() | Name | コード グループの名前を取得または設定します。 ( CodeGroup から継承されます。) |
![]() | PermissionSetName | オーバーライドされます。 コード グループの NamedPermissionSet の名前を取得します。 |
![]() | PolicyStatement | コード グループに関連付けられているポリシー ステートメントを取得または設定します。 ( CodeGroup から継承されます。) |

NetCodeGroup メソッド

名前 | 説明 | |
---|---|---|
![]() | AddChild | 子コード グループを現在のコード グループに追加します。 ( CodeGroup から継承されます。) |
![]() | AddConnectAccess | 指定された接続アクセスを現在のコード グループに追加します。 |
![]() | Copy | オーバーライドされます。 現在のコード グループの詳細コピーを作成します。 |
![]() | Equals | オーバーロードされます。 オーバーライドされます。 指定したコード グループが現在のコード グループと等しいかどうかを確認します。 |
![]() | FromXml | オーバーロードされます。 XML エンコーディングから、特定の状態のセキュリティ オブジェクトを再構築します。 ( CodeGroup から継承されます。) |
![]() | GetConnectAccessRules | 現在のコード グループの接続アクセス情報を取得します。 |
![]() | GetHashCode | オーバーライドされます。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | RemoveChild | 指定した子コード グループを削除します。 ( CodeGroup から継承されます。) |
![]() | ResetConnectAccess | 現在のコード グループの接続アクセス情報をすべて削除します。 |
![]() | Resolve | オーバーライドされます。 一連の証拠について、コード グループおよびその子孫のポリシーを解決します。 |
![]() | ResolveMatchingCodeGroups | オーバーライドされます。 一致しているコード グループを解決します。 |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |
![]() | ToXml | オーバーロードされます。 セキュリティ オブジェクトとその現在の状態を表す XML エンコーディングを作成します。 ( CodeGroup から継承されます。) |

NetCodeGroup メンバ
アセンブリのダウンロード元のサイトに Web アクセス許可を与えます。このクラスは継承できません。
NetCodeGroup データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | AbsentOriginScheme | コードの元のスキームが未知であるか、または認識されない場合にコードの接続アクセスを指定するための値を含みます。 |
![]() | AnyOtherOriginScheme | 他の指定されていない元のスキームを指定するために使用される値を含んでいます。 |

名前 | 説明 | |
---|---|---|
![]() | AttributeString | オーバーライドされます。 コード グループのポリシー ステートメントの属性の文字列形式を取得します。 |
![]() | Children | コード グループの子コード グループを順序付けして示したリストを取得または設定します。(CodeGroup から継承されます。) |
![]() | Description | コード グループの説明を取得または設定します。(CodeGroup から継承されます。) |
![]() | MembershipCondition | コード グループのメンバシップ条件を取得または設定します。(CodeGroup から継承されます。) |
![]() | MergeLogic | オーバーライドされます。 グループをマージするために使用するロジックを取得します。 |
![]() | Name | コード グループの名前を取得または設定します。(CodeGroup から継承されます。) |
![]() | PermissionSetName | オーバーライドされます。 コード グループの NamedPermissionSet の名前を取得します。 |
![]() | PolicyStatement | コード グループに関連付けられているポリシー ステートメントを取得または設定します。(CodeGroup から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | AddChild | 子コード グループを現在のコード グループに追加します。 (CodeGroup から継承されます。) |
![]() | AddConnectAccess | 指定された接続アクセスを現在のコード グループに追加します。 |
![]() | Copy | オーバーライドされます。 現在のコード グループの詳細コピーを作成します。 |
![]() | Equals | オーバーロードされます。 オーバーライドされます。 指定したコード グループが現在のコード グループと等しいかどうかを確認します。 |
![]() | FromXml | オーバーロードされます。 XML エンコーディングから、特定の状態のセキュリティ オブジェクトを再構築します。 (CodeGroup から継承されます。) |
![]() | GetConnectAccessRules | 現在のコード グループの接続アクセス情報を取得します。 |
![]() | GetHashCode | オーバーライドされます。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | RemoveChild | 指定した子コード グループを削除します。 (CodeGroup から継承されます。) |
![]() | ResetConnectAccess | 現在のコード グループの接続アクセス情報をすべて削除します。 |
![]() | Resolve | オーバーライドされます。 一連の証拠について、コード グループおよびその子孫のポリシーを解決します。 |
![]() | ResolveMatchingCodeGroups | オーバーライドされます。 一致しているコード グループを解決します。 |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |
![]() | ToXml | オーバーロードされます。 セキュリティ オブジェクトとその現在の状態を表す XML エンコーディングを作成します。 (CodeGroup から継承されます。) |

- NetCodeGroupのページへのリンク