UrlIdentityPermission 构造函数
定义
初始化 UrlIdentityPermission 类的新实例。Initializes a new instance of the UrlIdentityPermission class.
重载
| UrlIdentityPermission(PermissionState) |
使用指定的 UrlIdentityPermission 初始化 PermissionState 类的新实例。Initializes a new instance of the UrlIdentityPermission class with the specified PermissionState. |
| UrlIdentityPermission(String) |
初始化 UrlIdentityPermission 类的新实例,以表示 |
UrlIdentityPermission(PermissionState)
使用指定的 UrlIdentityPermission 初始化 PermissionState 类的新实例。Initializes a new instance of the UrlIdentityPermission class with the specified PermissionState.
public:
UrlIdentityPermission(System::Security::Permissions::PermissionState state);
public UrlIdentityPermission (System.Security.Permissions.PermissionState state);
new System.Security.Permissions.UrlIdentityPermission : System.Security.Permissions.PermissionState -> System.Security.Permissions.UrlIdentityPermission
Public Sub New (state As PermissionState)
参数
- state
- PermissionState
PermissionState 值之一。One of the PermissionState values.
例外
state 参数不是 PermissionState 的有效值。The state parameter is not a valid value of PermissionState.
示例
下面的示例演示如何使用 UrlIdentityPermission.UrlIdentityPermission(PermissionState) 构造函数。The following example shows the use of the UrlIdentityPermission.UrlIdentityPermission(PermissionState) constructor.
UrlIdentityPermission ^ permIdPerm2 = gcnew UrlIdentityPermission(PermissionState::None);
UrlIdentityPermission permIdPerm2 = new UrlIdentityPermission(PermissionState.None);
Dim permIdPerm2 As New UrlIdentityPermission(PermissionState.None)
注解
创建完全受限制的 (None) 或 Unrestricted 权限。Creates either a fully restricted (None) or Unrestricted permission.
备注
在 .NET Framework 版本1.0 和1.1 中,标识权限不能具有 Unrestricted 权限状态值。In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an Unrestricted permission state value. 从 .NET Framework 版本2.0 开始,标识权限可以具有任何权限状态值。Starting with the .NET Framework version 2.0, identity permissions can have any permission state value. 这意味着在2.0 及更高版本中,标识权限与实现该接口的权限具有相同的行为 IUnrestrictedPermission 。This means that in 2.0 and later versions, identity permissions have the same behavior as permissions that implement the IUnrestrictedPermission interface. 也就是说,如果程序集已被授予完全信任,则标识的请求始终会成功,无论程序集的标识如何都是如此。That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust.
在 .NET Framework 版本1.0 和1.1 中,对标识权限的要求有效,即使调用程序集是完全受信任的。In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective, even when the calling assembly is fully trusted. 也就是说,尽管调用程序集具有完全信任,但如果程序集不满足要求的条件,则标识权限的请求会失败。That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. 从 .NET Framework 版本2.0 开始,如果调用程序集具有完全信任,则标识权限要求将无效。Starting with the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. 这将确保所有权限的一致性,从而不会将标识权限视为一种特殊情况。This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
适用于
UrlIdentityPermission(String)
初始化 UrlIdentityPermission 类的新实例,以表示 site 所描述的 URL 标识。Initializes a new instance of the UrlIdentityPermission class to represent the URL identity described by site.
public:
UrlIdentityPermission(System::String ^ site);
public UrlIdentityPermission (string site);
new System.Security.Permissions.UrlIdentityPermission : string -> System.Security.Permissions.UrlIdentityPermission
Public Sub New (site As String)
参数
- site
- String
URL 或通配符表达式。A URL or wildcard expression.
例外
site 参数为 null。The site parameter is null.
site 参数的长度为零。The length of the site parameter is zero.
site 参数的 URL、目录或的站点部分无效。The URL, directory, or site portion of the site parameter is not valid.
示例
下面的示例演示如何使用 UrlIdentityPermission.UrlIdentityPermission(String) 构造函数。The following example shows the use of the UrlIdentityPermission.UrlIdentityPermission(String) constructor.
UrlIdentityPermission ^ permIdPerm1 = gcnew UrlIdentityPermission("http://www.fourthcoffee.com/process/");
UrlIdentityPermission permIdPerm1 = new UrlIdentityPermission("http://www.fourthcoffee.com/process/");
Dim permIdPerm1 As New UrlIdentityPermission("http://www.fourthcoffee.com/process/")
注解
将考虑完整的 URL,包括 (HTTP、HTTPS、FTP) 和文件的协议,例如: http://www.fourthcoffee.com/process/grind.htm/ 。The complete URL is considered, including the protocol (HTTP, HTTPS, FTP) and the file, for example: http://www.fourthcoffee.com/process/grind.htm/.
Url 可以完全与最终位置中的通配符匹配,例如: http://www.fourthcoffee.com/process/* 。URLs can be matched exactly or by a wildcard in the final position, for example: http://www.fourthcoffee.com/process/*. Url 还可以 * 在点分隔符上包含通配符 ( "" ) 前缀。URLs can also contain a wildcard ("*") prefix at the dot delimiter. 例如,URL 名称字符串 http://www.fourthcoffee.com/process/grind.htm/ 是和的子集 http://*.fourthcoffee.com/process/grind.htm/ http://*.com/process/grind.htm/ 。For example, the URL name string http://www.fourthcoffee.com/process/grind.htm/ is a subset of http://*.fourthcoffee.com/process/grind.htm/ and http://*.com/process/grind.htm/.
备注
从 .NET Framework 版本2.0 开始,出于性能方面的考虑,在创建新类实例时,无效的 URL 不会导致自变量异常。Starting with the .NET Framework version 2.0, for performance reasons, an invalid URL does not cause an argument exception at the time the new class instance is created. 当执行 (Union、Intersect 或 IsSubsetOf) 中的一个集操作时,将发生参数异常。The argument exception will occur when one of the set operations (Union, Intersect, or IsSubsetOf) is executed. 权限的需求将导致 IsSubsetOf 安全基础结构调用。A demand on the permission causes IsSubsetOf to be called by the security infrastructure. 由于参数异常,该请求将失败,从而导致 SecurityException 引发。The demand will fail because of the argument exception, resulting in a SecurityException being thrown. 在这种情况下, ArgumentException 将不会显示原始异常。In this case, the original ArgumentException exception will not be seen.