Connector/Net Programming
1934
<policy>
<PolicyLevel version="1">
<SecurityClasses>
....
<SecurityClass Name="MySqlClientPermission" Description="MySql.Data.MySqlClient.MySqlClientPermission, MySql.Data, Version=6.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
Scroll down to the
ASP.Net
section:
<PermissionSet class="NamedPermissionSet" version="1" Name="ASP.Net">
Add a new entry for the detailed configuration of the
MySqlClientPermission
class:
<IPermission class="MySqlClientPermission" version="1" Unrestricted="true"/>
Note: This configuration is the most generalized way that includes all keywords.
3. Configure the MySQL server to accept pipe connections, by adding the
--enable-named-pipe
option on the command line. If you need more information about this, see
Section 2.10, “Installing
MySQL on Microsoft Windows”
.
4. Confirm that the hosting provider has installed the Connector/Net library (
MySql.Data.dll
) in the
GAC.
5. Optionally, the hosting provider can avoid granting permissions globally by using
the new
MySqlClientPermission
class in the trust policies. (The alternative
is to globally enable the permissions
System.Net.SocketPermission
,
System.Security.Permissions.ReflectionPermission
,
System.Net.DnsPermission
,
and
System.Security.Permissions.SecurityPermission
.)
6. Create a simple web application using Visual Studio 2010.
7. Add the reference in your application for the
MySql.Data.MySqlClient
library.
8. Edit your
web.config
file so that your application runs using a Medium trust level:
<system.web>
<trust level="Medium"/>
</system.web>
9. Add the
MySql.Data.MySqlClient
namespace to your server-code page.
10. Define the connection string, in slightly different ways depending on the Connector/Net version.
Only for 6.6.4 or later: To use the connections inside any web application that will run in
Medium trust, add the new
includesecurityasserts
option to the connection string.
includesecurityasserts=true
that makes the library request the following permissions
when required:
SocketPermissions
,
ReflectionPermissions
,
DnsPermissions
,
SecurityPermissions
among others that are not granted in Medium trust levels.
For Connector/Net 6.6.3 or earlier: No special setting for security is needed within the connection
string.
MySqlConnectionStringBuilder myconnString = new MySqlConnectionStringBuilder("server=localhost;User Id=root;database=test;");
myconnString.PipeName = "MySQL55";
myconnString.ConnectionProtocol = MySqlConnectionProtocol.Pipe;
// Following attribute is a new requirement when the library is in the GAC.
// Could also be done by adding includesecurityasserts=true; to the string literal
// in the constructor above.
// Not needed with Connector/Net 6.6.3 and earlier.myconnString.IncludeSecurityAsserts = true;
11. Define the
MySqlConnection
to use:
MySqlConnection myconn = new MySqlConnection(myconnString.ConnectionString);
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...