cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: LDAP support in libcurl

From: Henrik Storner <henrik-curl_at_hswn.dk>
Date: Sun, 31 Aug 2003 17:39:29 +0200

It turned out to be somewhat simpler than I thought.

The attached patch results in a libcurl that groks LDAP
URL's and outputs a sensible plain-text representation of
the attributes. The patch is against libcurl 7.10.7, and
has been tested with OpenLDAP 2.1.22 (the current version);
however, the principles behind the code have also been tested
against OpenLDAP 2.0.26 so it should work.

The patch adds a new libcurl error code: CURLE_LDAP_INVALID_URL,
which is returned if the ldap_url_parse() function detects an
invalid URL.

There is one issue with this patch that I am uncomfortable with.
The ldap_url_parse() function returns a struct with the broken-
down elements of the request URL. However, the ldap_search_s()
function requires that each of the elements of the LDAP request
are passed as separate parameters. Therefore, my patch adds
a copy of the LDAPURLDesc structure definition to the CURL code.
If this struct is changed in a later OpenLDAP release - or is
defined differently by another LDAP library - the code breaks.
But I cannot see how this can be avoided, unless the LDAP-
library's own <ldap.h> is used (in which case libcurl's ldap.h
file should probably be re-named).

Regards,
Henrik

-- 
Henrik Storner <henrik_at_hswn.dk> 

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

Received on 2003-08-31