This class allows you to ensure that the current process has the required code access security permission to access the SQL Server provider before executing code that will interact with the database. It also allows you to temporarily revoke this permission. Typically, you apply this attribute to the declaration of a method that accesses the database or to the definition of a class that contains data access code in every method. You can also apply the attribute to an assembly, struct, or constructor. The SqlClientPermissionAttribute provides essentially the same functionality as the SqlClientPermission class, but it allows you to add declarative security code instead of explicit (inline) code.

Note that this attribute pertains only to code access security (the policy of allowed and disallowed actions you have configured using the .NET Framework Configuration Tool). It has nothing to do with the authentication process that SQL Server will use. For more information, refer to the reference for the base class System.Data.Common.DBDataPermissionAttribute. Currently, the only code access security restriction that you can apply to the SQL Server managed provider is denying the permission to use blank passwords in the connection string.

public sealed class SqlClientPermissionAttribute : System.Data.Common.DBDataPermissionAttribute {

// Public Constructors

   public SqlClientPermissionAttribute(System.Security.Permissions.SecurityAction action);

// Public ...

Get ADO.NET in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.