Skip site navigation (1) Skip section navigation (2)

OpenLDAP and PostgreSQL

From: Gilles DAROLD <gilles(at)darold(dot)net>
Subject: OpenLDAP and PostgreSQL
Date: 2001-07-27 18:53:16
Message-ID: (view raw or flat)
Lists: pgsql-generalpgsql-odbc
Hi all,

I've passed the entire week to try to run Openldap over PostgreSQL and have
maby troubles. All the documentation and mail I had found seem not really
working, at least
for me. Seeing my time lost to have this working a documentation seems
necessary for this
more and more openLDAP asked feature. I've in plan to write a working HOWTO for
this or
contribute to one in work and I would like to compare my experience with

Here is what I've done:

- Write the first lines of a HOWTO for installation and configuration.
- Able to give some working samples.
- Write a portable patch to cast the objectClass statement in OpenLDAP. The
patch proposed is not portable and need a new slapd.conf option. I will submit
it to the
OpenLDAP team next week.

I still have some trouble with entry creation that finish to make me crazy.


I always received the same id (134551209) when inserting multiple entries, so
integrity failed. For example, to load this LDIFF data:

    cn: User Test_Add_Entry
    sn: User Test_Add_Entry
    objectClass: person

I have 'create_proc' set to "SELECT set_person_name(?,?)" and the function is:

CREATE FUNCTION create_person(int4)
        INSERT INTO persons (id, name) VALUES ($1, '' '');
        SELECT 1;

Given argument is 134551209 (???)
    DEBUG:  query: SELECT create_person(134551209)

I use SELECT 1; as final query of the function because whatever I want to
(like a current sequence number) is not return or at least I don't know how to
it back to the next following query.

Here 'add_proc' is set to "SELECT set_person_name(?,?)" and the function is:

CREATE FUNCTION set_person_name(int4, varchar)
        UPDATE persons SET name=text($2) WHERE $1=id;
        SELECT 1;

Given arg1 is 134551209 and arg2 'User Test_Add_Entry'
    DEBUG:  query: SELECT set_person_name(134551209,'User Test_Add_Entry')

And then the ldap_entry is inserted like that:

DEBUG:  query: INSERT INTO ldap_entries (id,dn,oc_map_id,parent,keyval)
VALUES (currval('ldap_entries_id_seq'),'cn= User Test_Add_Entry,o=sql,c=RU',

Ok, this works but when I insert more dn I always get the same id 134551209 so
all next queries fail.

What does it means ? I have trace a little what openldap is doing and it seams
(possibly wrong, my knowledge with C++ and ODBC is not enougth) that the
ODBC function SQLBindParamater never update the rgbValue that is used to
set a new identifier. Am I wrong ? Is anybody have ever seen that ?

I'm using PostgreSQL 7.1.2, libiodbc-3.0.5 compiled with libpsqlodbc provided
in 7.1.2 and openldap-2.0.11.

The only workaround I've found is using sequences to first create the entry
and then modify the entry to set the attributes. That works pretty well but
permit direct LDIFF export/import.

Thanks for your help,


In response to

pgsql-odbc by date

Next:From: Hiroshi InoueDate: 2001-07-27 22:17:17
Subject: RE: A problem with the nextval('') function
Previous:From: Ryan C. BonhamDate: 2001-07-27 16:59:36
Subject: Visual Basic and PostgreSQL ODBC

pgsql-general by date

Next:From: Andre SchnabelDate: 2001-07-27 19:06:50
Subject: Re: Database Design Question
Previous:From: Mike MascariDate: 2001-07-27 18:31:58
Subject: Re: Re: D308-E9AF-4C11 : CONFIRM from pgsql-sql (subscribe)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group