Hello ldapers, I have been working to add a read-only ldap gateway to a mysql database. I want to do this for an application called phpOrganisation (www.phporg.net). The app runs with mysql version 4.x. I've followed the various howtos and now have a view of parts of the sql database, both my own database and also the example database distributed with the openldap source. I can access the various entries using an ldap client (in my case, I'm using phpldapadmin). However, if I try to search the database things get sticky. Here is the portion of the slapd output which I think is relevant. This is a search of the example database: ------------------------------- backsql_process_sub_filter(cn): expr: 'persons.name' '' <==backsql_process_filter_attr(cn) <==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 ldap_entries.dn LIKE ? AND ( LIKE 'MITYA%') 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 ldap_entries.dn LIKE ? AND ( LIKE 'MITYA%') id: '1' (sub)dn: "%o=sql,c=RU" backsql_oc_get_candidates(): error executing query Return code: -1 Native error code: 1064 SQL engine state: 37000 Message: [unixODBC][MySQL][ODBC 3.51 Driver][mysqld-4.0.25]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIKE 'MITYA%')' at line 1 backsql_search(): loading data for entry id=5, oc_id=2, keyval=1 ------------------------------ The query which is contructed doesn't appear to be valid SQL as far as mysqld is concerned. Here is the query which backsql_srch_query() contructs: 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 ldap_entries.dn LIKE ? AND ( LIKE 'MITYA%') The problem is in the last line. I don't know enough sql to tell if this could be valid sql on another rdbms, but if I change the last line to AND (cn LIKE 'MITYA%') Then the query will run. I note that mysql isn't terribly well used with back-sql, or at least the maintainers of back-sql don't have enough time to test with mysql. Is there anything I can add to my metadata to have the 'cn' added to that search query, or do I need to hack backsql_srch_query() in search.c in the back-sql code? regards, Seb James -- Embedded Software Foundry Ltd. 'Embedded Linux Development' Tel: +44 (0)845 4580277 Web: http://www.esfnet.co.uk/ Axiom Tech Open Source Member: http://www.axiomtech.co.uk/ Gpg key: http://www.esfnet.co.uk/ssl/seb.gpg
Attachment:
signature.asc
Description: This is a digitally signed message part