3. Configuration

3.1. ODBC

With unixODBC or libiodbc you have to configuration file: odbc.ini and odbcinst.ini. Here are samples configuration files I use for this HOWTO:

3.1.1. odbc.ini

Just copy this file into the /usr/local/etc or /etc directory following your installation.


;
;  odbc.ini
;
[ODBC Data Sources]
PgSQL=PostgreSQL

[PgSQL]
; WARNING: The old psql odbc driver psqlodbc.so is now renamed psqlodbcw.so
; in version 08.x. Note that the library can also be installed under an other
; path than /usr/local/lib/ following your installation.
Driver=/usr/local/lib/psqlodbcw.so
Description=Connection to LDAP/POSTGRESQL
Servername=localhost
Port=5432
Protocol=6.4
FetchBufferSize=99
Username=test
Password=test
Database=pg_ldap
ReadOnly=no
Debug=1
CommLog=1

[ODBC]
InstallDir=/usr/local/lib

3.1.2. odbcinst.ini

Normally the installation of psqlodbc library has already created this file, if not just copy this file into the /usr/local/etc or /etc directory, following your installation.


;
;  odbcinst.ini
;
[PostgreSQL]
Description=ODBC for PostgreSQL
; WARNING: The old psql odbc driver psqlodbc.so is now renamed psqlodbcw.so
; in version 08.x. Note that the library can also be installed under an other
; path than /usr/local/lib/ following your installation.
Driver=/usr/local/lib/psqlodbcw.so

[ODBC]
Trace=1
Debug=1
Pooling=No

3.2. OpenLDAP

You have to configure OpenLDAP to use the SQL backend, which database and some other SQL related specific option. See below:

3.2.1. slapd.conf

Just copy the file openldap-2.X.XX/servers/slapd/back-sql/rdbms_depend/pgsql/slapd.conf into the /usr/local/etc/openldap/ directory and change the dbname, dbuser, dbpasswd values as follow:


#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include         /usr/local/etc/openldap/schema/core.schema
include         /usr/local/etc/openldap/schema/cosine.schema
include         /usr/local/etc/openldap/schema/inetorgperson.schema

# Define global ACLs to disable default read access.
# Define global ACLs to disable default read access.
access to *
        by self write
        by * read
access to * by dn="cn=root,dc=example,dc=com" write

# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral       ldap://root.openldap.org

pidfile         /usr/local/var/slapd.pid
argsfile        /usr/local/var/slapd.args

#######################################################################
# sql database definitions
#######################################################################

database        sql
suffix         "dc=example,dc=com"
rootdn         "cn=root,dc=example,dc=com"
rootpw          secret
dbname          PgSQL
dbuser          test
dbpasswd        test
insentry_stmt  "insert into ldap_entries (id,dn,oc_map_id,parent,keyval) values ((select max(id)+1 from ldap_entries),?,?,?,?)"
upper_func      "upper"
strcast_func    "text"
concat_pattern  "?||?"
has_ldapinfo_dn_ru      no

lastmod off

See "man slapd-sql" if you want to know more about the SQL related options. Also if you never take a look to the slapd.conf file begining with "man slapd.conf" should be a good choice.

3.3. PostgreSQL

There's no special configuration options to give to PostgreSQL. We just need to create the test database and the test user.

You must su to user postgres or any other PostgreSQL superuser to perform the following task.