[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Unix sockets connection to server ?

[continuing on from openldap-general post on domain
 socket transport for OpenLDAP                     ]

I found a cleaner way to integrate ldapi URL searching,
which was probably the obvious thing to do all along,
namely adding the extra line of code to ldap_url_search()
to pass along the domain socket flag. :-)


    ld = ldap_init(NULL, LDAP_PORT);
    if (ld == NULL) {
        return 1;

    rc = LDAP_VERSION3;
    (void) ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &rc);
    rc = ldap_url_search_s(ld, "ldapi://%2Ftmp%2F.ldap-sock/?+", 0, &res);

In order to get this to work, I had to comment some code
out in request.c. In ldap_send_initial_request(), we check
whether the sockbuf is connected or not, and if not, open
the default connection. However, this connection had 
already been opened (to the domain socket) and calling
ldap_open_defconn() clobbered it with a TCP connection.
I checked the Mozilla SDK and this snippet of code wasn't
there. Perhaps it should be removed altogether.

#ifndef USE_PF_LOCAL 
        if ( ! ber_pvt_sb_in_use(&ld->ld_sb ) ) {
                /* not connected yet */
                int rc = ldap_open_defconn( ld );

                if( rc < 0 ) {
                        ber_free( ber, 1 );
                        return( -1 );
#endif /* USE_PF_LOCAL */


-- Luke

Luke Howard
PADL Software Pty Ltd