I'm trying to come up with a plan to allow users to auth with a MySQL database (many, actually) using LDAP. More specifically, ActiveDirectory. Database will likely be accessed through applications, not web. What are my options?
EDIT:
Okay. It seems that there is no "official" way to allow authentication on MySQL using LDAP. What other options exist? Can we synchronize LDAP users and passwords to the MySQL user table?
You can use the auth_ldap plugin provided by Infoscope Hellas L.P. under GPL.
It can be downloaded from sourceforge at: http://sourceforge.net/projects/mysqlauthldap/
Homepage: http://infoscope.gr/mysqlauthldap
The plugin is still a Beta and works only for UNIX installations.
Now that's it has been a decade since the original post the answer is finally yes to there being an official LDAP connection method for MySQL. It however does require you be running the MySQL Enterprise Edition or MySQL Cluster CGE versions.
MySQL Enterprise Authentication
This is definitely possible. See here: https://www.percona.com/blog/2017/04/21/how-to-setup-and-troubleshoot-percona-pam-with-ldap-for-external-authentication/
In my environment, I did not set up Samba or NSS/SSS and I do not join the windows domain. I just treat the AD server as an LDAP endpoint. So I started from Step 9 in the above directions.
EDIT: Add instructions from above link as suggested by AfroThundr
Install the Percona PAM plugin:
Configure Percona PAM to authenticate to LDAP by creating /etc/pam.d/mysqld with this content:
Create a MySQL user that will authenticate via auth_pam:
Login as this user and check grants:
Also beware of AppArmor - it will block the auth attempt. You may see misleading error messages in
/var/log/auth.log
:You need to add the following to
/etc/apparmor.d/local/usr.sbin.mysqld
:#include <abstractions/authentication>
and reload apparmor:
service apparmor restart
(Thanks to https://bugs.launchpad.net/ubuntu/+source/squid/+bug/1608984 for leading me to the AppArmor part)
Now by the end of 2017, I can suggest this:
https://www.percona.com/doc/percona-server/LATEST/management/pam_plugin.html
It is NOT tested, I do not know yet how good it is.
Seems like you are out of luck :(
Could you use PostgreSQL?
This is possible now with commercial extensions, e.g. with MySQL External Authentication for Windows:
This enables you to configure MySQL 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 token information in their environment without specifying an additional password.