ZoneIdentityPermission 类

定义

警告:已过时

Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}

为代码的来源区域定义标识权限。Defines the identity permission for the zone from which the code originates. 此类不能被继承。This class cannot be inherited.

public ref class ZoneIdentityPermission sealed : System::Security::CodeAccessPermission
public sealed class ZoneIdentityPermission : System.Security.CodeAccessPermission
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public sealed class ZoneIdentityPermission : System.Security.CodeAccessPermission
[System.Serializable]
public sealed class ZoneIdentityPermission : System.Security.CodeAccessPermission
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ZoneIdentityPermission : System.Security.CodeAccessPermission
type ZoneIdentityPermission = class
    inherit CodeAccessPermission
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type ZoneIdentityPermission = class
    inherit CodeAccessPermission
[<System.Serializable>]
type ZoneIdentityPermission = class
    inherit CodeAccessPermission
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ZoneIdentityPermission = class
    inherit CodeAccessPermission
Public NotInheritable Class ZoneIdentityPermission
Inherits CodeAccessPermission
继承
ZoneIdentityPermission
属性

注解

此权限可确定调用代码是否来自特定区域。This permission can determine whether calling code is from a certain zone. 区域根据 Microsoft Internet Explorer 选项进行配置,并通过 Internet Explorer 的 IInternetSecurityManager 和相关 Api 从 URL 映射。Zones are configured according to the Microsoft Internet Explorer options, and are mapped from URL by Internet Explorer's IInternetSecurityManager and related APIs. 仅为权限定义了精确区域匹配;一个 URL 只能属于一个区域。Only exact zone matches are defined for the permission; a URL can only belong to one zone.

  • 本地 intranet 区域:本地 intranet 区域用于位于公司 intranet 上的内容。Local intranet zone: The Local intranet zone is used for content located on a company's intranet. 由于服务器在公司的防火墙内,因此 intranet 上的内容分配有更高的信任级别。Because the servers are within a company's firewall, content on the intranet is assigned a higher level of trust.

  • 受信任的站点区域:受信任的站点区域用于网站上的内容,这些内容被视为比 Internet 上的其他站点更具信誉或值得信任的内容。Trusted sites zone: The Trusted sites zone is used for content located on Web sites that are considered more reputable or trustworthy than other sites on the Internet. 用户可以使用此区域向特定的 Internet 站点分配更高的信任级别。Users can use this zone to assign a higher level of trust to specific Internet sites. 这些受信任的网站的 URL 需要由用户映射到该区域中。The URLs of these trusted Web sites need to be mapped into this zone by the user. 默认情况下,受信任的站点区域中的站点与 Internet 区域中的站点不会获得更高的信任。By default, sites in the Trusted sites zone receive no higher trust than those in the Internet zone. 如果用户或公司希望为此区域包含的站点提供更高级别的信任,则需要更改授予此区域的信任级别。A user or company needs to change the level of trust granted to this zone if they want the sites it contains to be given a higher level of trust.

  • Internet 区域: internet 区域用于 Internet 上不属于其他区域的网站。Internet zone: The Internet zone is used for the Web sites on the Internet that do not belong to another zone. 默认设置允许从这些站点下载的代码只需对用户计算机上的资源进行最小限度的访问。The default settings allow code downloaded from these sites only minimal access to resources on the user's computer. 未映射到其他区域的网站会自动归入此区域。Web sites that are not mapped into other zones automatically fall into this zone.

  • 受限制的站点区域:受限制的站点区域用于包含可能会导致或可能在下载时出现问题的内容的网站。Restricted sites zone: The Restricted sites zone is used for Web sites that contain content that could cause, or could have previously caused, problems when downloaded. 此区域可用于阻止从这些站点下载的代码在用户的计算机上运行。This zone could be used to prevent code downloaded from these sites from running on the user's computer. 这些不受信任的网站的 URL 需要由用户映射到该区域中。The URLs of these untrusted Web sites need to be mapped into this zone by the user.

  • 本地计算机区域:本地计算机区域是一个隐式区域,用于在用户的计算机上存在的内容。Local Machine zone: The Local Machine zone is an implicit zone that is used for content that exists on the user's computer. 用户计算机上的内容(由本地系统上的 Internet Explorer 缓存的内容除外)被视为非常高的信任级别。The content found on the user's computer, except for content cached by Internet Explorer on the local system, is treated with a very high level of trust.

重要

从开始 .NET Framework 4.NET Framework 4 ,不使用标识权限。Starting with the .NET Framework 4.NET Framework 4, identity permissions are not used.

在 .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.

构造函数

ZoneIdentityPermission(PermissionState)

使用指定的 ZoneIdentityPermission 初始化 PermissionState 类的新实例。Initializes a new instance of the ZoneIdentityPermission class with the specified PermissionState.

ZoneIdentityPermission(SecurityZone)

初始化 ZoneIdentityPermission 类的新实例,以表示指定的区域标识。Initializes a new instance of the ZoneIdentityPermission class to represent the specified zone identity.

属性

SecurityZone

获取或设置由当前 ZoneIdentityPermission 表示的区域。Gets or sets the zone represented by the current ZoneIdentityPermission.

方法

Assert()

声明调用代码能够通过调用此方法的代码,访问受权限请求保护的资源,即使未对堆栈中处于较高位置的调用方授予访问该资源的权限。Declares that the calling code can access the resource protected by a permission demand through the code that calls this method, even if callers higher in the stack have not been granted permission to access the resource. 使用 Assert() 会引起安全问题。Using Assert() can create security issues.

(继承自 CodeAccessPermission)
Copy()

创建并返回当前权限的相同副本。Creates and returns an identical copy of the current permission.

Demand()

如果未对调用堆栈中处于较高位置的所有调用方授予当前实例所指定的权限,则在运行时强制 SecurityExceptionForces a SecurityException at run time if all callers higher in the call stack have not been granted the permission specified by the current instance.

(继承自 CodeAccessPermission)
Deny()
已过时。
已过时。

防止处于调用堆栈较高位置的调用函数使用可以调用此方法来访问当前实例指定资源的代码。Prevents callers higher in the call stack from using the code that calls this method to access the resource specified by the current instance.

(继承自 CodeAccessPermission)
Equals(Object)

确定指定的 CodeAccessPermission 对象是否等于当前的 CodeAccessPermissionDetermines whether the specified CodeAccessPermission object is equal to the current CodeAccessPermission.

(继承自 CodeAccessPermission)
FromXml(SecurityElement)

从 XML 编码重新构造具有指定状态的权限。Reconstructs a permission with a specified state from an XML encoding.

GetHashCode()

获取 CodeAccessPermission 对象的哈希代码,此代码适合在哈希算法和数据结构(例如哈希表)中使用。Gets a hash code for the CodeAccessPermission object that is suitable for use in hashing algorithms and data structures such as a hash table.

(继承自 CodeAccessPermission)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
Intersect(IPermission)

创建并返回一个权限,该权限是当前权限与指定权限的交集。Creates and returns a permission that is the intersection of the current permission and the specified permission.

IsSubsetOf(IPermission)

确定当前权限是否为指定权限的子集。Determines whether the current permission is a subset of the specified permission.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
PermitOnly()

防止处于调用堆栈较高位置的调用函数使用此代码,此代码将调用此方法来访问除当前实例指定的资源以外的所有资源。Prevents callers higher in the call stack from using the code that calls this method to access all resources except for the resource specified by the current instance.

(继承自 CodeAccessPermission)
ToString()

创建并返回当前权限对象的字符串表示形式。Creates and returns a string representation of the current permission object.

(继承自 CodeAccessPermission)
ToXml()

创建权限及其当前状态的 XML 编码。Creates an XML encoding of the permission and its current state.

Union(IPermission)

创建一个权限,该权限是当前权限与指定权限的并集。Creates a permission that is the union of the current permission and the specified permission.

显式接口实现

IPermission.Demand()

如果不满足安全要求,则会在运行时引发 SecurityExceptionThrows a SecurityException at run time if the security requirement is not met.

(继承自 CodeAccessPermission)
IStackWalk.Assert()

断言调用代码可以访问当前权限对象所标识的资源,即使尚未对堆栈中的高级调用方授予访问该资源的权限。Asserts that the calling code can access the resource identified by the current permission object, even if callers higher in the stack have not been granted permission to access the resource.

(继承自 CodeAccessPermission)
IStackWalk.Demand()

在运行时确定调用堆栈中的所有调用方是否已被授予当前权限对象所指定的权限。Determines at run time whether all callers in the call stack have been granted the permission specified by the current permission object.

(继承自 CodeAccessPermission)
IStackWalk.Deny()

将导致通过调用代码传递的当前对象的每个 Demand() 失败。Causes every Demand() for the current object that passes through the calling code to fail.

(继承自 CodeAccessPermission)
IStackWalk.PermitOnly()

导致所有对象的每个 Demand()(除了通过调用代码的当前那个)失败,即使调用堆栈中较高级别的代码已被授予访问其他资源的权限也是如此。Causes every Demand() for all objects except the current one that pass through the calling code to fail, even if code higher in the call stack has been granted permission to access other resources.

(继承自 CodeAccessPermission)

适用于

另请参阅