Hi,
Thanks for the quick answer. I have added the line you suggested and now I have "No database selected" mysql error I have run "isql -v MySQL ldap ldap" and it works...
[root@server ~]# isql -v MySQL ldap ldap +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+
Somehow the dbname parameter is not transmited..
--- ### the slapd -d -1 output ---
<<< dnPrettyNormal: <dc=example,dc=com>, <dc=example,dc=com> <==backsql_dn2id("dc=example,dc=com"): err=0 ==>backsql_id2entry() backsql_id2entry(): retrieving all attributes ==>backsql_get_attr_vals(): oc="organization" attr="o" keyval=1 backsql_get_attr_vals(): error executing attribute count query 'SELECT COUNT(*) FROM institutes WHERE institutes.id=?' Return code: -1 nativeErrCode=1046 SQLengineState=3D000 msg="[unixODBC][MySQL][ODBC 3.51 Driver][mysqld-5.0.77-log]No database selected" ==>backsql_get_attr_vals(): oc="organization" attr="dc" keyval=1 backsql_get_attr_vals(): error executing attribute count query 'SELECT COUNT(*) FROM institutes,ldap_entries AS dcObject,ldap_entry_objclasses AS auxObjectClass WHERE institutes.id=? AND institutes.id=dcObject.keyval AND dcObject.oc_map_id=3 AND dcObject.id=auxObjectClass.entry_id AND auxObjectClass.oc_name='dcObject'' Return code: -1 nativeErrCode=1046 SQLengineState=3D000 msg="[unixODBC][MySQL][ODBC 3.51 Driver][mysqld-5.0.77-log]No database selected" ==>backsql_get_attr_vals(): oc="organization" attr="objectClass" keyval=1 backsql_get_attr_vals(): error executing attribute count query 'SELECT COUNT(*) FROM ldap_entry_objclasses,ldap_entries,institutes WHERE institutes.id=? AND ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entries.keyval=institutes.id and ldap_entries.oc_map_id=3' Return code: -1 nativeErrCode=1046 SQLengineState=3D000 msg="[unixODBC][MySQL][ODBC 3.51 Driver][mysqld-5.0.77-log]No database selected" <==backsql_id2entry() ==>backsql_oc_get_candidates(): oc="document" ==>backsql_srch_query() ==>backsql_process_filter() <==backsql_process_filter() succeeded <==backsql_srch_query() returns SELECT DISTINCT ldap_entries.id,documents.id,'document' AS objectClass,ldap_entries.dn AS dn FROM ldap_entries,documents WHERE documents.id=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND 9=9 AND 3=3 Constructed query: SELECT DISTINCT ldap_entries.id,documents.id,'document' AS objectClass,ldap_entries.dn AS dn FROM ldap_entries,documents WHERE documents.id=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND 9=9 AND 3=3 id: '2' backsql_oc_get_candidates(): error executing query Return code: -1 nativeErrCode=1046 SQLengineState=3D000 msg="[unixODBC][MySQL][ODBC 3.51 Driver][mysqld-5.0.77-log]No database selected" ==>backsql_oc_get_candidates(): oc="referral" ==>backsql_srch_query() ==>backsql_process_filter() <==backsql_process_filter() succeeded <==backsql_srch_query() returns SELECT DISTINCT ldap_entries.id,referrals.id,'referral' AS objectClass,ldap_entries.dn AS dn FROM ldap_entries,referrals WHERE referrals.id=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND 9=9 AND 3=3 Constructed query: SELECT DISTINCT ldap_entries.id,referrals.id,'referral' AS objectClass,ldap_entries.dn AS dn FROM ldap_entries,referrals WHERE referrals.id=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND 9=9 AND 3=3 id: '4' backsql_oc_get_candidates(): error executing query Return code: -1 nativeErrCode=1046 SQLengineState=3D000 msg="[unixODBC][MySQL][ODBC 3.51 Driver][mysqld-5.0.77-log]No database selected" ==>backsql_oc_get_candidates(): oc="organization" ==>backsql_srch_query() ==>backsql_process_filter() <==backsql_process_filter() succeeded <==backsql_srch_query() returns SELECT DISTINCT ldap_entries.id,institutes.id,'organization' AS objectClass,ldap_entries.dn AS dn FROM ldap_entries,institutes WHERE institutes.id=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND 9=9 AND 3=3 Constructed query: SELECT DISTINCT ldap_entries.id,institutes.id,'organization' AS objectClass,ldap_entries.dn AS dn FROM ldap_entries,institutes WHERE institutes.id=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND 9=9 AND 3=3 id: '3' backsql_oc_get_candidates(): error executing query Return code: -1 nativeErrCode=1046 SQLengineState=3D000 msg="[unixODBC][MySQL][ODBC 3.51 Driver][mysqld-5.0.77-log]No database selected" ==>backsql_oc_get_candidates(): oc="inetOrgPerson" ==>backsql_srch_query() ==>backsql_process_filter() <==backsql_process_filter() succeeded <==backsql_srch_query() returns SELECT DISTINCT ldap_entries.id,persons.id,'inetOrgPerson' AS objectClass,ldap_entries.dn AS dn FROM ldap_entries,persons WHERE persons.id=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND 9=9 AND 3=3 Constructed query: SELECT DISTINCT ldap_entries.id,persons.id,'inetOrgPerson' AS objectClass,ldap_entries.dn AS dn FROM ldap_entries,persons WHERE persons.id=ldap_entries.keyval AND ldap_entries.oc_map_id=? AND 9=9 AND 3=3 id: '1' backsql_oc_get_candidates(): error executing query Return code: -1 nativeErrCode=1046 SQLengineState=3D000 msg="[unixODBC][MySQL][ODBC 3.51 Driver][mysqld-5.0.77-log]No database selected" send_ldap_result: conn=0 op=1 p=3 send_ldap_result: err=80 matched="" text="" send_ldap_response: msgid=2 tag=101 err=80 ber_flush: 14 bytes to sd 8 0000: 30 0c 02 01 02 65 07 0a 01 50 04 00 04 00 0....e...P.... ldap_write: want=14, written=14 0000: 30 0c 02 01 02 65 07 0a 01 50 04 00 04 00 0....e...P.... conn=0 op=1 SEARCH RESULT tag=101 err=80 nentries=0 text= <==backsql_search() daemon: activity on 1 descriptor daemon: activity on: 8r daemon: read active on 8 daemon: epoll: listen=7 active_threads=0 tvp=NULL connection_get(8) connection_get(8): got connid=0 connection_read(8): checking for input on id=0 ber_get_next ldap_read: want=8, got=7 0000: 30 05 02 01 03 42 00 0....B. ber_get_next: tag 0x30 len 5 contents: ber_dump: buf=0x2b541e7ed5c0 ptr=0x2b541e7ed5c0 end=0x2b541e7ed5c5 len=5 0000: 02 01 03 42 00 ...B. ber_get_next ldap_read: want=8, got=0
ber_get_next on fd 8 failed errno=0 (Success) connection_read(8): input error=-2 id=0, closing. connection_closing: readying conn=0 sd=8 for close connection_close: deferring conn=0 sd=8 do_unbind conn=0 op=2 UNBIND connection_resched: attempting closing conn=0 sd=8 connection_close: conn=0 sd=8 ==>backsql_connection_destroy() ==>backsql_free_db_conn() backsql_free_db_conn(): closing db connection 0 (0x2b541e8152d0) ==>backsql_close_db_conn(0) <==backsql_close_db_conn(0) <==backsql_free_db_conn() <==backsql_connection_destroy() daemon: removing 8 conn=0 fd=8 closed daemon: activity on 1 descriptor daemon: activity on: daemon: epoll: listen=7 active_threads=0 tvp=NULL
-----Original Message----- From: masarati@aero.polimi.it [mailto:masarati@aero.polimi.it] Sent: Saturday, September 24, 2011 12:15 PM To: Victor LAZA Cc: openldap-technical@openldap.org Subject: Re: OpenLDAP with MySQL backend not working
Hi all,
I am using OpenLDAP with MySQL backend for testing purpose, a future project of linux authentication via LDAP but with MySQL backend.
Did you check slapd-sql(5) and the example slapd.conf(5) for mysql that is distributed with the package in servers/slapd/back-sql/rdbms_depend/mysql/slapd.conf ? The logs
backsql_dn2id("dc=example,dc=com"): id_query "SELECT id,keyval,oc_map_id,dn FROM `ldap_test`.`ldap_entries` WHERE dn=?"
backsql_dn2id("dc=example,dc=com"): upperdn="MOC=CD,ELPMAXE=CD"
<==backsql_dn2id("dc=example,dc=com"): err=32
clearly show the DN is being reversed while uppercased for normalization. You need to set
has_ldapinfo_dn_ru no
to prevent this, as in the example configuration. I don't see it set in your slapd.conf.
p.
----- No virus found in this message. Checked by AVG - www.avg.com Version: 2012.0.1809 / Virus Database: 2085/4513 - Release Date: 09/22/11