PDF (A4) - 41.5Mb
Man Pages (TGZ) - 272.3Kb
Man Pages (Zip) - 378.2Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb
Windows pluggable authentication is an extension included in MySQL Enterprise Edition, a commercial product. To learn more about commercial products, seehttps://www.mysql.com/products/.
MySQL Enterprise Edition for Windows supports an authentication method that performs external authentication on Windows, enabling MySQL Server to use native Windows services to authenticate client connections. Users who have logged in to Windows can connect from MySQL client programs to the server based on the information in their environment without specifying an additional password.
The client and server exchange data packets in the authentication handshake. As a result of this exchange, the server creates a security context object that represents the identity of the client in the Windows OS. This identity includes the name of the client account. Windows pluggable authentication uses the identity of the client to check whether it is a given account or a member of a group. By default, negotiation uses Kerberos to authenticate, then NTLM if Kerberos is unavailable.
Windows pluggable authentication provides these capabilities:
External authentication: Windows authentication enables MySQL Server to accept connections from users defined outside the MySQL grant tables who have logged in to Windows.
Proxy user support: Windows authentication can return to MySQL a user name different from the external user name passed by the client program. This means that the plugin can return the MySQL user that defines the privileges the external Windows-authenticated user should have. For example, a Windows user named
joecan connect and have the privileges of a MySQL user nameddeveloper.
The following table shows the plugin and library file names. The file must be located in the directory named by theplugin_dir system variable.
Table 8.18 Plugin and Library Names for Windows Authentication
| Plugin or File | Plugin or File Name |
|---|---|
| Server-side plugin | authentication_windows |
| Client-side plugin | authentication_windows_client |
| Library file | authentication_windows.dll |
The library file includes only the server-side plugin. The client-side plugin is built into thelibmysqlclient client library.
The server-side Windows authentication plugin is included only in MySQL Enterprise Edition. It is not included in MySQL community distributions. The client-side plugin is included in all distributions, including community distributions. This enables clients from any distribution to connect to a server that has the server-side plugin loaded.
The following sections provide installation and usage information specific to Windows pluggable authentication:
For general information about pluggable authentication in MySQL, seeSection 8.2.17, “Pluggable Authentication”. For proxy user information, seeSection 8.2.19, “Proxy Users”.
This section describes how to install the server-side Windows authentication plugin. For general information about installing plugins, seeSection 7.6.1, “Installing and Uninstalling Plugins”.
To be usable by the server, the plugin library file must be located in the MySQL plugin directory (the directory named by theplugin_dir system variable). If necessary, configure the plugin directory location by setting the value ofplugin_dir at server startup.
To load the plugin at server startup, use the--plugin-load-add option to name the library file that contains it. With this plugin-loading method, the option must be given each time the server starts. For example, put these lines in the servermy.cnf file:
[mysqld]plugin-load-add=authentication_windows.dll After modifyingmy.cnf, restart the server to cause the new settings to take effect.
Alternatively, to load the plugin at runtime, use this statement:
INSTALL PLUGIN authentication_windows SONAME 'authentication_windows.dll';INSTALL PLUGIN loads the plugin immediately, and also registers it in themysql.plugins system table to cause the server to load it for each subsequent normal startup without the need for--plugin-load-add.
To verify plugin installation, examine the Information SchemaPLUGINS table or use theSHOW PLUGINS statement (seeSection 7.6.2, “Obtaining Server Plugin Information”). For example:
mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE '%windows%';+------------------------+---------------+| PLUGIN_NAME | PLUGIN_STATUS |+------------------------+---------------+| authentication_windows | ACTIVE |+------------------------+---------------+If the plugin fails to initialize, check the server error log for diagnostic messages.
To associate MySQL accounts with the Windows authentication plugin, seeUsing Windows Pluggable Authentication. Additional plugin control is provided by theauthentication_windows_use_principal_name andauthentication_windows_log_level system variables. SeeSection 7.1.8, “Server System Variables”.
The method used to uninstall the Windows authentication plugin depends on how you installed it:
If you installed the plugin at server startup using a
--plugin-load-addoption, restart the server without the option.If you installed the plugin at runtime using an
INSTALL PLUGINstatement, it remains installed across server restarts. To uninstall it, useUNINSTALL PLUGIN:UNINSTALL PLUGIN authentication_windows;
In addition, remove any startup options that set Windows plugin-related system variables.
The Windows authentication plugin supports the use of MySQL accounts such that users who have logged in to Windows can connect to the MySQL server without having to specify an additional password. It is assumed that the server is running with the server-side plugin enabled, as described inInstalling Windows Pluggable Authentication. Once the DBA has enabled the server-side plugin and set up accounts to use it, clients can connect using those accounts with no other setup required on their part.
To refer to the Windows authentication plugin in theIDENTIFIED WITH clause of aCREATE USER statement, use the nameauthentication_windows. Suppose that the Windows usersRafal andTasha should be permitted to connect to MySQL, as well as any users in theAdministrators orPower Users group. To set this up, create a MySQL account namedsql_admin that uses the Windows plugin for authentication:
CREATE USER sql_admin IDENTIFIED WITH authentication_windows AS 'Rafal, Tasha, Administrators, "Power Users"'; The plugin name isauthentication_windows. The string following theAS keyword is the authentication string. It specifies that the Windows users namedRafal orTasha are permitted to authenticate to the server as the MySQL usersql_admin, as are any Windows users in theAdministrators orPower Users group. The latter group name contains a space, so it must be quoted with double quote characters.
After you create thesql_admin account, a user who has logged in to Windows can attempt to connect to the server using that account:
C:\> mysql --user=sql_admin No password is required here. Theauthentication_windows plugin uses the Windows security API to check which Windows user is connecting. If that user is namedRafal orTasha, or is a member of theAdministrators orPower Users group, the server grants access and the client is authenticated assql_admin and has whatever privileges are granted to thesql_admin account. Otherwise, the server denies access.
Authentication string syntax for the Windows authentication plugin follows these rules:
The string consists of one or more user mappings separated by commas.
Each user mapping associates a Windows user or group name with a MySQL user name:
win_user_or_group_name=mysql_user_namewin_user_or_group_nameFor the latter syntax, with no
mysql_user_namevalue given, the implicit value is the MySQL user created by theCREATE USERstatement. Thus, these statements are equivalent:CREATE USER sql_admin IDENTIFIED WITH authentication_windows AS 'Rafal, Tasha, Administrators, "Power Users"';CREATE USER sql_admin IDENTIFIED WITH authentication_windows AS 'Rafal=sql_admin, Tasha=sql_admin, Administrators=sql_admin, "Power Users"=sql_admin';Each backslash character (
\) in a value must be doubled because backslash is the escape character in MySQL strings.Leading and trailing spaces not inside double quotation marks are ignored.
Unquoted
win_user_or_group_nameandmysql_user_namevalues can contain anything except equal sign, comma, or space.If a
win_user_or_group_nameand ormysql_user_namevalue is quoted with double quotation marks, everything between the quotation marks is part of the value. This is necessary, for example, if the name contains space characters. All characters within double quotes are legal except double quotation mark and backslash. To include either character, escape it with a backslash.win_user_or_group_namevalues use conventional syntax for Windows principals, either local or in a domain. Examples (note the doubling of backslashes):domain\\user.\\userdomain\\group.\\groupBUILTIN\\WellKnownGroup
When invoked by the server to authenticate a client, the plugin scans the authentication string left to right for a user or group match to the Windows user. If there is a match, the plugin returns the correspondingmysql_user_name to the MySQL server. If there is no match, authentication fails.
A user name match takes preference over a group name match. Suppose that the Windows user namedwin_user is a member ofwin_group and the authentication string looks like this:
'win_group = sql_user1, win_user = sql_user2' Whenwin_user connects to the MySQL server, there is a match both towin_group and towin_user. The plugin authenticates the user assql_user2 because the more-specific user match takes precedence over the group match, even though the group is listed first in the authentication string.
Windows authentication always works for connections from the same computer on which the server is running. For cross-computer connections, both computers must be registered with Microsoft Active Directory. If they are in the same Windows domain, it is unnecessary to specify a domain name. It is also possible to permit connections from a different domain, as in this example:
CREATE USER sql_accounting IDENTIFIED WITH authentication_windows AS 'SomeDomain\\Accounting'; HereSomeDomain is the name of the other domain. The backslash character is doubled because it is the MySQL escape character within strings.
MySQL supports the concept of proxy users whereby a client can connect and authenticate to the MySQL server using one account but while connected has the privileges of another account (seeSection 8.2.19, “Proxy Users”). Suppose that you want Windows users to connect using a single user name but be mapped based on their Windows user and group names onto specific MySQL accounts as follows:
The
local_userandMyDomain\domain_userlocal and domain Windows users should map to thelocal_wladMySQL account.Users in the
MyDomain\Developersdomain group should map to thelocal_devMySQL account.Local machine administrators should map to the
local_adminMySQL account.
To set this up, create a proxy account for Windows users to connect to, and configure this account so that users and groups map to the appropriate MySQL accounts (local_wlad,local_dev,local_admin). In addition, grant the MySQL accounts the privileges appropriate to the operations they need to perform. The following instructions usewin_proxy as the proxy account, andlocal_wlad,local_dev, andlocal_admin as the proxied accounts.
Create the proxy MySQL account:
CREATE USER win_proxy IDENTIFIED WITH authentication_windows AS 'local_user = local_wlad, MyDomain\\domain_user = local_wlad, MyDomain\\Developers = local_dev, BUILTIN\\Administrators = local_admin';For proxying to work, the proxied accounts must exist, so create them:
CREATE USER local_wlad IDENTIFIED WITH mysql_no_login;CREATE USER local_dev IDENTIFIED WITH mysql_no_login;CREATE USER local_admin IDENTIFIED WITH mysql_no_login;The proxied accounts use the
mysql_no_loginauthentication plugin to prevent clients from using the accounts to log in directly to the MySQL server. Instead, users who authenticate using Windows are expected to use thewin_proxyproxy account. (This assumes that the plugin is installed. For instructions, seeSection 8.4.1.8, “No-Login Pluggable Authentication”.) For alternative methods of protecting proxied accounts against direct use, seePreventing Direct Login to Proxied Accounts.You should also execute
GRANTstatements (not shown) that grant each proxied account the privileges required for MySQL access.Grant to the proxy account the
PROXYprivilege for each proxied account:GRANT PROXY ON local_wlad TO win_proxy;GRANT PROXY ON local_dev TO win_proxy;GRANT PROXY ON local_admin TO win_proxy;
Now the Windows userslocal_user andMyDomain\domain_user can connect to the MySQL server aswin_proxy and when authenticated have the privileges of the account given in the authentication string (in this case,local_wlad). A user in theMyDomain\Developers group who connects aswin_proxy has the privileges of thelocal_dev account. A user in theBUILTIN\Administrators group has the privileges of thelocal_admin account.
To configure authentication so that all Windows users who do not have their own MySQL account go through a proxy account, substitute the default proxy account (''@'') forwin_proxy in the preceding instructions. For information about default proxy accounts, seeSection 8.2.19, “Proxy Users”.
If your MySQL installation has anonymous users, they might conflict with the default proxy user. For more information about this issue, and ways of dealing with it, seeDefault Proxy User and Anonymous User Conflicts.
To use the Windows authentication plugin with Connector/NET connection strings in Connector/NET 9.5 and higher, seeConnector/NET Authentication.
PDF (A4) - 41.5Mb
Man Pages (TGZ) - 272.3Kb
Man Pages (Zip) - 378.2Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb