CodeGroupType Enumeration
Assembly: System.Net.Security.dll
CodeGroupType
Indicates the type of a code group.
Members
| Member | Value | Description |
|---|---|---|
| SecurityAdmin | 0 |
Indicates that the code group is a security administrator code group. |
| Hash | 1 |
Indicates that the code group is a hash-based code group. |
| Site | 2 |
Indicates that the code group is a site-based code group. |
| StrongName | 3 |
Indicates that the code group is a strong-name code group. |
| Url | 4 |
Indicates that the code group is a URL-based code group. |
| Zone | 5 |
Indicates that the code group is a zone-based code group. |
Remarks
The CodeGroupType enumeration is used by the Code Access Security (CAS) model to categorize code groups.
Each type of code group corresponds to a different criteria for granting permissions to code. For example, a Site code group grants permissions to code originating from a specific website.
Requirements
Client: Supported in: .NET Framework 4.5, .NET Framework 4.5.1, .NET Framework 4.5.2, .NET Framework 4.6, .NET Framework 4.6.1, .NET Framework 4.6.2, .NET Framework 4.7, .NET Framework 4.7.1, .NET Framework 4.7.2, .NET Framework 4.8, .NET Core 2.0, .NET Core 2.1, .NET Core 2.2, .NET Core 3.0, .NET Core 3.1, .NET 5, .NET 6, .NET 7, .NET 8
Server: Supported in: .NET Framework 4.5, .NET Framework 4.5.1, .NET Framework 4.5.2, .NET Framework 4.6, .NET Framework 4.6.1, .NET Framework 4.6.2, .NET Framework 4.7, .NET Framework 4.7.1, .NET Framework 4.7.2, .NET Framework 4.8, .NET Core 2.0, .NET Core 2.1, .NET Core 2.2, .NET Core 3.0, .NET Core 3.1, .NET 5, .NET 6, .NET 7, .NET 8
Product: .NET
Example
The following example demonstrates how to check the type of a CodeGroup.
using System;
using System.Net.Security;
using System.Security.Policy;
public class Example
{
public static void Main(string[] args)
{
// Assume 'codeGroup' is an existing CodeGroup object
CodeGroup codeGroup = new UrlSecurityPermissionCollection().CreateCodeGroup(); // Placeholder for actual code group creation
if (codeGroup != null)
{
CodeGroupType type = codeGroup.Attribute & CodeGroupType.TypeMask; // Mask to get the type
switch (type)
{
case CodeGroupType.SecurityAdmin:
Console.WriteLine("Code group is a Security Admin type.");
break;
case CodeGroupType.Hash:
Console.WriteLine("Code group is a Hash type.");
break;
case CodeGroupType.Site:
Console.WriteLine("Code group is a Site type.");
break;
case CodeGroupType.StrongName:
Console.WriteLine("Code group is a Strong Name type.");
break;
case CodeGroupType.Url:
Console.WriteLine("Code group is a URL type.");
break;
case CodeGroupType.Zone:
Console.WriteLine("Code group is a Zone type.");
break;
default:
Console.WriteLine($"Unknown code group type: {type}");
break;
}
}
}
}