SqlClientPermission 类

定义

启用用于 SQL Server 的 .NET Framework 数据提供程序,帮助确保用户具有足够的安全级别来访问数据源。Enables the .NET Framework Data Provider for SQL Server to help make sure that a user has a security level sufficient to access a data source.

public ref class SqlClientPermission sealed : System::Data::Common::DBDataPermission
public sealed class SqlClientPermission : System.Data.Common.DBDataPermission
[System.Serializable]
public sealed class SqlClientPermission : System.Data.Common.DBDataPermission
type SqlClientPermission = class
    inherit DBDataPermission
Public NotInheritable Class SqlClientPermission
Inherits DBDataPermission
继承
属性

注解

IsUnrestricted 属性优先于 AllowBlankPassword 属性。The IsUnrestricted property takes precedence over the AllowBlankPassword property. 因此,如果将 AllowBlankPassword 设置为 false,则还必须将 IsUnrestricted 设置为 false,以防止用户使用空白密码建立连接。Therefore, if you set AllowBlankPassword to false, you must also set IsUnrestricted to false to prevent a user from making a connection using a blank password.

备注

对 ADO.NET 使用代码访问安全权限时,正确的模式是从最严格的情况(无权限)开始,然后添加代码需要执行的特定任务所需的特定权限。When using code access security permissions for ADO.NET, the correct pattern is to start with the most restrictive case (no permissions at all) and then add the specific permissions that are needed for the particular task that the code needs to perform. 相反,从所有权限开始,然后拒绝特定权限的模式并不安全,因为有多种方法可表示相同的连接字符串。The opposite pattern, starting with all permissions and then denying a specific permission, is not secure, because there are many ways of expressing the same connection string. 例如,如果一开始就授予所有权限,然后尝试拒绝使用连接字符串“server=someserver”,则仍将允许使用“server=someserver.mycompany.com”。For example, if you start with all permissions and then attempt to deny the use of the connection string "server=someserver", the string "server=someserver.mycompany.com" would still be allowed. 通过在开始时始终不授予任何权限,可以降低权限集中存在漏洞的几率。By always starting by granting no permissions at all, you reduce the chances that there are holes in the permission set.

构造函数

SqlClientPermission()

初始化 SqlClientPermission 类的新实例。Initializes a new instance of the SqlClientPermission class.

SqlClientPermission(PermissionState)

初始化 SqlClientPermission 类的新实例。Initializes a new instance of the SqlClientPermission class.

SqlClientPermission(PermissionState, Boolean)

初始化 SqlClientPermission 类的新实例。Initializes a new instance of the SqlClientPermission class.

属性

AllowBlankPassword

获取一个值,该值指示是否允许使用空白密码。Gets a value indicating whether a blank password is allowed.

(继承自 DBDataPermission)

方法

Add(String, String, KeyRestrictionBehavior)

SqlClientPermission 对象添加新的连接字符串和一组限制性关键字。Adds a new connection string and a set of restricted keywords to the SqlClientPermission object.

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)
Clear()

移除以前使用 Add(String, String, KeyRestrictionBehavior) 方法添加的所有权限。Removes all permissions that were previous added using the Add(String, String, KeyRestrictionBehavior) method.

(继承自 DBDataPermission)
Copy()

SqlClientPermission 形式返回 IPermissionReturns the SqlClientPermission as an IPermission.

CreateInstance()

创建 DBDataPermission 类的新实例。Creates a new instance of the DBDataPermission class.

(继承自 DBDataPermission)
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 security object with a specified state from an XML encoding.

(继承自 DBDataPermission)
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)

返回表示当前权限对象和指定权限对象的交集的新权限对象。Returns a new permission object representing the intersection of the current permission object and the specified permission object.

(继承自 DBDataPermission)
IsSubsetOf(IPermission)

返回一个值,该值指示当前的权限对象是否为指定权限对象的一个子集。Returns a value indicating whether the current permission object is a subset of the specified permission object.

(继承自 DBDataPermission)
IsUnrestricted()

返回一个值,该值指示在不了解权限语义的情况下是否可以将权限表示为无限制。Returns a value indicating whether the permission can be represented as unrestricted without any knowledge of the permission semantics.

(继承自 DBDataPermission)
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 security object and its current state.

(继承自 DBDataPermission)
Union(IPermission)

返回一个新的权限对象,它是当前权限对象和指定权限对象的并集。Returns a new permission object that is the union of the current and specified permission objects.

(继承自 DBDataPermission)

显式接口实现

IPermission.Demand() (继承自 CodeAccessPermission)
IStackWalk.Assert() (继承自 CodeAccessPermission)
IStackWalk.Demand() (继承自 CodeAccessPermission)
IStackWalk.Deny() (继承自 CodeAccessPermission)
IStackWalk.PermitOnly() (继承自 CodeAccessPermission)

适用于

另请参阅