Backsql


From Docunext Technology Wiki

Jump to: navigation, search

Contents

Summary

Backsql is a component of OpenLDAP which allows the use of a SQL storage mechanism for the back end, such as MySQL. I've set this up once before and it worked pretty well. I'm going to try it out again and I'm planning to take better notes this time! :-) Actually, I just found my old notes:

OpenLDAP and MySQL Documentation Notes at the Docunext Blog

Patented?

Interesting! While searching for information on this matter, I found a patent on a "ldap to sql proxy module".

http://www.google.com/patents?id=C8ObAAAAEBAJ

I believe there to be prior art, but I am not a lawyer! The application was filed in 2005, and there are references to such a concept in 2004, and it may have been invented much earlier:

http://web.archive.org/web/20051223231727/www.flatmtn.com/computer/Linux-LDAP.html#LdapBacksql

Yeah, here's a CVS revision from openldap in 1999: http://www.openldap.org/devel/cvsweb.cgi/~checkout~/servers/slapd/back-sql/sql-wrap.c?rev=1.1&hideattic=1&sortbydate=0


Backsql on Debian

ODBC Setup

Roughly followed my old notes about setting up LDAP Backsql on Gentoo:

User and password are specified in slapd.conf, but the database must be correct.

[myodbc3]
Driver       = /usr/lib/odbc/libmyodbc.so
Setup        = /usr/lib/odbc/libodbcmyS.so
Description  = MySQL ODBC 3.51 Driver DSN
Server       = localhost
Port         =
User         = root
Password     = foobar
Database     = backsql_test
Option       = 3
Socket       =

then...

odbcinst -q -d mysql -f /etc/odbc.ini

Slapd configuration

# Schema and objectClass definitions
include         /etc/ldap/schema/core.schema
include         /etc/ldap/schema/cosine.schema
include         /etc/ldap/schema/nis.schema
include         /etc/ldap/schema/inetorgperson.schema

pidfile         /var/run/slapd/slapd.pid

# List of arguments that were passed to the server
argsfile        /var/run/slapd/slapd.args

loglevel        none
modulepath  /usr/lib/ldap
moduleload      back_sql

sizelimit 500
tool-threads 1
backend         sql

database        sql

# The base of your directory in database #1
suffix          "dc=example,dc=com"
rootdn          "cn=admin,dc= example,dc=com"
rootpw          skoobydoobie
dbname          myodbc3
dbuser          root
dbpasswd        skoobydoobie

subtree_cond    "ldap_entries.dn LIKE CONCAT('%',?)"
insentry_query  "INSERT INTO ldap_entries (dn,oc_map_id,parent,keyval)
        VALUES (?,?,?,?)"

It works for me!

Next Steps

Need to read up on this article again:

As I want to be able to store user data in a simpler manner, and use a view to generate the LDAP entries:

CREATE VIEW ldap_entries_test (id,dn,oc_map_id,parent,keyval) AS SELECT uid,CONCAT('uid=',uid,',ou=contacts,dc=docunext,dc=com'),2,1,uid FROM auth_user;

See Also

Links

Personal tools