1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
23 #include "curl_setup.h"
25 #if !defined(CURL_DISABLE_LDAP) && !defined(USE_OPENLDAP)
28 * Notice that USE_OPENLDAP is only a source code selection switch. When
29 * libcurl is built with USE_OPENLDAP defined the libcurl source code that
30 * gets compiled is the code from openldap.c, otherwise the code that gets
31 * compiled is the code from ldap.c.
33 * When USE_OPENLDAP is defined a recent version of the OpenLDAP library
34 * might be required for compilation and runtime. In order to use ancient
35 * OpenLDAP library versions, USE_OPENLDAP shall not be defined.
38 #ifdef USE_WIN32_LDAP /* Use Windows LDAP implementation. */
40 # ifndef LDAP_VENDOR_NAME
41 # error Your Platform SDK is NOT sufficient for LDAP support! \
42 Update your Platform SDK, or disable LDAP support!
47 # define LDAP_DEPRECATED 1 /* Be sure ldap_init() is defined. */
52 # if (defined(HAVE_LDAP_SSL) && defined(HAVE_LDAP_SSL_H))
53 # include <ldap_ssl.h>
54 # endif /* HAVE_LDAP_SSL && HAVE_LDAP_SSL_H */
57 /* These are macros in both <wincrypt.h> (in above <winldap.h>) and typedefs
58 * in BoringSSL's <openssl/x509.h>
62 # undef X509_CERT_PAIR
63 # undef X509_EXTENSIONS
67 #include <curl/curl.h>
74 #include "curl_ldap.h"
75 #include "curl_multibyte.h"
76 #include "curl_base64.h"
79 #include "curl_printf.h"
81 /* The last #include files should be: */
82 #include "curl_memory.h"
85 #ifndef HAVE_LDAP_URL_PARSE
87 /* Use our own implementation. */
92 #if defined(USE_WIN32_LDAP)
100 #if defined(USE_WIN32_LDAP)
106 size_t lud_attrs_dups; /* how many were dup'ed, this field is not in the
107 "real" struct so can only be used in code
108 without HAVE_LDAP_URL_PARSE defined */
112 #define LDAPURLDesc CURL_LDAPURLDesc
114 static int _ldap_url_parse (const struct connectdata *conn,
116 static void _ldap_free_urldesc (LDAPURLDesc *ludp);
118 #undef ldap_free_urldesc
119 #define ldap_free_urldesc _ldap_free_urldesc
123 #define LDAP_TRACE(x) do { \
124 _ldap_trace ("%u: ", __LINE__); \
128 static void _ldap_trace (const char *fmt, ...);
130 #define LDAP_TRACE(x) Curl_nop_stmt
134 static CURLcode Curl_ldap(struct connectdata *conn, bool *done);
137 * LDAP protocol handler.
140 const struct Curl_handler Curl_handler_ldap = {
142 ZERO_NULL, /* setup_connection */
143 Curl_ldap, /* do_it */
144 ZERO_NULL, /* done */
145 ZERO_NULL, /* do_more */
146 ZERO_NULL, /* connect_it */
147 ZERO_NULL, /* connecting */
148 ZERO_NULL, /* doing */
149 ZERO_NULL, /* proto_getsock */
150 ZERO_NULL, /* doing_getsock */
151 ZERO_NULL, /* domore_getsock */
152 ZERO_NULL, /* perform_getsock */
153 ZERO_NULL, /* disconnect */
154 ZERO_NULL, /* readwrite */
155 PORT_LDAP, /* defport */
156 CURLPROTO_LDAP, /* protocol */
157 PROTOPT_NONE /* flags */
162 * LDAPS protocol handler.
165 const struct Curl_handler Curl_handler_ldaps = {
166 "LDAPS", /* scheme */
167 ZERO_NULL, /* setup_connection */
168 Curl_ldap, /* do_it */
169 ZERO_NULL, /* done */
170 ZERO_NULL, /* do_more */
171 ZERO_NULL, /* connect_it */
172 ZERO_NULL, /* connecting */
173 ZERO_NULL, /* doing */
174 ZERO_NULL, /* proto_getsock */
175 ZERO_NULL, /* doing_getsock */
176 ZERO_NULL, /* domore_getsock */
177 ZERO_NULL, /* perform_getsock */
178 ZERO_NULL, /* disconnect */
179 ZERO_NULL, /* readwrite */
180 PORT_LDAPS, /* defport */
181 CURLPROTO_LDAPS, /* protocol */
182 PROTOPT_SSL /* flags */
187 static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
189 CURLcode result = CURLE_OK;
192 LDAPURLDesc *ludp = NULL;
193 LDAPMessage *ldapmsg = NULL;
194 LDAPMessage *entryIterator;
196 struct SessionHandle *data=conn->data;
197 int ldap_proto = LDAP_VERSION3;
199 char *val_b64 = NULL;
200 size_t val_b64_sz = 0;
201 curl_off_t dlsize = 0;
202 #ifdef LDAP_OPT_NETWORK_TIMEOUT
203 struct timeval ldap_timeout = {10, 0}; /* 10 sec connection/search timeout */
205 #if defined(USE_WIN32_LDAP)
208 TCHAR *passwd = NULL;
215 *done = TRUE; /* unconditionally */
216 infof(data, "LDAP local: LDAP Vendor = %s ; LDAP Version = %d\n",
217 LDAP_VENDOR_NAME, LDAP_VENDOR_VERSION);
218 infof(data, "LDAP local: %s\n", data->change.url);
220 #ifdef HAVE_LDAP_URL_PARSE
221 rc = ldap_url_parse(data->change.url, &ludp);
223 rc = _ldap_url_parse(conn, &ludp);
226 failf(data, "LDAP local: %s", ldap_err2string(rc));
227 result = CURLE_LDAP_INVALID_URL;
231 /* Get the URL scheme ( either ldap or ldaps ) */
232 if(conn->given->flags & PROTOPT_SSL)
234 infof(data, "LDAP local: trying to establish %s connection\n",
235 ldap_ssl ? "encrypted" : "cleartext");
237 #if defined(USE_WIN32_LDAP)
238 host = Curl_convert_UTF8_to_tchar(conn->host.name);
240 result = CURLE_OUT_OF_MEMORY;
245 if(conn->bits.user_passwd) {
246 user = Curl_convert_UTF8_to_tchar(conn->user);
247 passwd = Curl_convert_UTF8_to_tchar(conn->passwd);
248 if(!user || !passwd) {
249 result = CURLE_OUT_OF_MEMORY;
255 host = conn->host.name;
257 if(conn->bits.user_passwd) {
259 passwd = conn->passwd;
263 #ifdef LDAP_OPT_NETWORK_TIMEOUT
264 ldap_set_option(NULL, LDAP_OPT_NETWORK_TIMEOUT, &ldap_timeout);
266 ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
270 #ifdef USE_WIN32_LDAP
271 /* Win32 LDAP SDK doesn't support insecure mode without CA! */
272 server = ldap_sslinit(host, (int)conn->port, 1);
273 ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON);
276 char* ldap_ca = data->set.str[STRING_SSL_CAFILE];
277 #if defined(CURL_HAS_NOVELL_LDAPSDK)
278 rc = ldapssl_client_init(NULL, NULL);
279 if(rc != LDAP_SUCCESS) {
280 failf(data, "LDAP local: ldapssl_client_init %s", ldap_err2string(rc));
281 result = CURLE_SSL_CERTPROBLEM;
284 if(data->set.ssl.verifypeer) {
285 /* Novell SDK supports DER or BASE64 files. */
286 int cert_type = LDAPSSL_CERT_FILETYPE_B64;
287 if((data->set.str[STRING_CERT_TYPE]) &&
288 (Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "DER")))
289 cert_type = LDAPSSL_CERT_FILETYPE_DER;
291 failf(data, "LDAP local: ERROR %s CA cert not set!",
292 (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"));
293 result = CURLE_SSL_CERTPROBLEM;
296 infof(data, "LDAP local: using %s CA cert '%s'\n",
297 (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
299 rc = ldapssl_add_trusted_cert(ldap_ca, cert_type);
300 if(rc != LDAP_SUCCESS) {
301 failf(data, "LDAP local: ERROR setting %s CA cert: %s",
302 (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
303 ldap_err2string(rc));
304 result = CURLE_SSL_CERTPROBLEM;
307 ldap_option = LDAPSSL_VERIFY_SERVER;
310 ldap_option = LDAPSSL_VERIFY_NONE;
311 rc = ldapssl_set_verify_mode(ldap_option);
312 if(rc != LDAP_SUCCESS) {
313 failf(data, "LDAP local: ERROR setting cert verify mode: %s",
314 ldap_err2string(rc));
315 result = CURLE_SSL_CERTPROBLEM;
318 server = ldapssl_init(host, (int)conn->port, 1);
320 failf(data, "LDAP local: Cannot connect to %s:%ld",
321 conn->host.dispname, conn->port);
322 result = CURLE_COULDNT_CONNECT;
325 #elif defined(LDAP_OPT_X_TLS)
326 if(data->set.ssl.verifypeer) {
327 /* OpenLDAP SDK supports BASE64 files. */
328 if((data->set.str[STRING_CERT_TYPE]) &&
329 (!Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "PEM"))) {
330 failf(data, "LDAP local: ERROR OpenLDAP only supports PEM cert-type!");
331 result = CURLE_SSL_CERTPROBLEM;
335 failf(data, "LDAP local: ERROR PEM CA cert not set!");
336 result = CURLE_SSL_CERTPROBLEM;
339 infof(data, "LDAP local: using PEM CA cert: %s\n", ldap_ca);
340 rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
341 if(rc != LDAP_SUCCESS) {
342 failf(data, "LDAP local: ERROR setting PEM CA cert: %s",
343 ldap_err2string(rc));
344 result = CURLE_SSL_CERTPROBLEM;
347 ldap_option = LDAP_OPT_X_TLS_DEMAND;
350 ldap_option = LDAP_OPT_X_TLS_NEVER;
352 rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
353 if(rc != LDAP_SUCCESS) {
354 failf(data, "LDAP local: ERROR setting cert verify mode: %s",
355 ldap_err2string(rc));
356 result = CURLE_SSL_CERTPROBLEM;
359 server = ldap_init(host, (int)conn->port);
361 failf(data, "LDAP local: Cannot connect to %s:%ld",
362 conn->host.dispname, conn->port);
363 result = CURLE_COULDNT_CONNECT;
366 ldap_option = LDAP_OPT_X_TLS_HARD;
367 rc = ldap_set_option(server, LDAP_OPT_X_TLS, &ldap_option);
368 if(rc != LDAP_SUCCESS) {
369 failf(data, "LDAP local: ERROR setting SSL/TLS mode: %s",
370 ldap_err2string(rc));
371 result = CURLE_SSL_CERTPROBLEM;
375 rc = ldap_start_tls_s(server, NULL, NULL);
376 if(rc != LDAP_SUCCESS) {
377 failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s",
378 ldap_err2string(rc));
379 result = CURLE_SSL_CERTPROBLEM;
384 /* we should probably never come up to here since configure
385 should check in first place if we can support LDAP SSL/TLS */
386 failf(data, "LDAP local: SSL/TLS not supported with this version "
387 "of the OpenLDAP toolkit\n");
388 result = CURLE_SSL_CERTPROBLEM;
392 #endif /* CURL_LDAP_USE_SSL */
395 server = ldap_init(host, (int)conn->port);
397 failf(data, "LDAP local: Cannot connect to %s:%ld",
398 conn->host.dispname, conn->port);
399 result = CURLE_COULDNT_CONNECT;
403 #ifdef USE_WIN32_LDAP
404 ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
407 rc = ldap_simple_bind_s(server, user, passwd);
408 if(!ldap_ssl && rc != 0) {
409 ldap_proto = LDAP_VERSION2;
410 ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
411 rc = ldap_simple_bind_s(server, user, passwd);
414 failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
415 result = CURLE_LDAP_CANNOT_BIND;
419 rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
420 ludp->lud_filter, ludp->lud_attrs, 0, &ldapmsg);
422 if(rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
423 failf(data, "LDAP remote: %s", ldap_err2string(rc));
424 result = CURLE_LDAP_SEARCH_FAILED;
428 for(num = 0, entryIterator = ldap_first_entry(server, ldapmsg);
430 entryIterator = ldap_next_entry(server, entryIterator), num++) {
431 BerElement *ber = NULL;
432 #if defined(USE_WIN32_LDAP)
435 char *attribute; /*! suspicious that this isn't 'const' */
439 /* Get the DN and write it to the client */
443 #if defined(USE_WIN32_LDAP)
444 TCHAR *dn = ldap_get_dn(server, entryIterator);
445 name = Curl_convert_tchar_to_UTF8(dn);
449 result = CURLE_OUT_OF_MEMORY;
454 char *dn = name = ldap_get_dn(server, entryIterator);
456 name_len = strlen(name);
458 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
460 #if defined(USE_WIN32_LDAP)
461 Curl_unicodefree(name);
468 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *) name,
471 #if defined(USE_WIN32_LDAP)
472 Curl_unicodefree(name);
479 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
481 #if defined(USE_WIN32_LDAP)
482 Curl_unicodefree(name);
489 dlsize += name_len + 5;
491 #if defined(USE_WIN32_LDAP)
492 Curl_unicodefree(name);
497 /* Get the attributes and write them to the client */
498 for(attribute = ldap_first_attribute(server, entryIterator, &ber);
500 attribute = ldap_next_attribute(server, entryIterator, ber)) {
503 #if defined(USE_WIN32_LDAP)
504 char *attr = Curl_convert_tchar_to_UTF8(attribute);
509 result = CURLE_OUT_OF_MEMORY;
514 char *attr = attribute;
516 attr_len = strlen(attr);
518 vals = ldap_get_values_len(server, entryIterator, attribute);
520 for(i = 0; (vals[i] != NULL); i++) {
521 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
523 ldap_value_free_len(vals);
524 #if defined(USE_WIN32_LDAP)
525 Curl_unicodefree(attr);
527 ldap_memfree(attribute);
534 result = Curl_client_write(conn, CLIENTWRITE_BODY,
535 (char *) attr, attr_len);
537 ldap_value_free_len(vals);
538 #if defined(USE_WIN32_LDAP)
539 Curl_unicodefree(attr);
541 ldap_memfree(attribute);
548 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
550 ldap_value_free_len(vals);
551 #if defined(USE_WIN32_LDAP)
552 Curl_unicodefree(attr);
554 ldap_memfree(attribute);
561 dlsize += attr_len + 3;
564 (strcmp(";binary", (char *) attr + (attr_len - 7)) == 0)) {
565 /* Binary attribute, encode to base64. */
566 result = Curl_base64_encode(data,
572 ldap_value_free_len(vals);
573 #if defined(USE_WIN32_LDAP)
574 Curl_unicodefree(attr);
576 ldap_memfree(attribute);
584 result = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64,
588 ldap_value_free_len(vals);
589 #if defined(USE_WIN32_LDAP)
590 Curl_unicodefree(attr);
592 ldap_memfree(attribute);
599 dlsize += val_b64_sz;
603 result = Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
606 ldap_value_free_len(vals);
607 #if defined(USE_WIN32_LDAP)
608 Curl_unicodefree(attr);
610 ldap_memfree(attribute);
617 dlsize += vals[i]->bv_len;
620 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
622 ldap_value_free_len(vals);
623 #if defined(USE_WIN32_LDAP)
624 Curl_unicodefree(attr);
626 ldap_memfree(attribute);
636 /* Free memory used to store values */
637 ldap_value_free_len(vals);
640 /* Free the attribute as we are done with it */
641 #if defined(USE_WIN32_LDAP)
642 Curl_unicodefree(attr);
644 ldap_memfree(attribute);
646 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
650 Curl_pgrsSetDownloadCounter(data, dlsize);
659 ldap_msgfree(ldapmsg);
660 LDAP_TRACE (("Received %d entries\n", num));
662 if(rc == LDAP_SIZELIMIT_EXCEEDED)
663 infof(data, "There are more than %d entries\n", num);
665 ldap_free_urldesc(ludp);
667 ldap_unbind_s(server);
668 #if defined(HAVE_LDAP_SSL) && defined(CURL_HAS_NOVELL_LDAPSDK)
670 ldapssl_client_deinit();
671 #endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
673 #if defined(USE_WIN32_LDAP)
674 Curl_unicodefree(passwd);
675 Curl_unicodefree(user);
676 Curl_unicodefree(host);
679 /* no data to transfer */
680 Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
681 connclose(conn, "LDAP connection always disable re-use");
687 static void _ldap_trace (const char *fmt, ...)
689 static int do_trace = -1;
693 const char *env = getenv("CURL_TRACE");
694 do_trace = (env && strtol(env, NULL, 10) > 0);
699 va_start (args, fmt);
700 vfprintf (stderr, fmt, args);
705 #ifndef HAVE_LDAP_URL_PARSE
708 * Return scope-value for a scope-string.
710 static int str2scope (const char *p)
712 if(strequal(p, "one"))
713 return LDAP_SCOPE_ONELEVEL;
714 if(strequal(p, "onetree"))
715 return LDAP_SCOPE_ONELEVEL;
716 if(strequal(p, "base"))
717 return LDAP_SCOPE_BASE;
718 if(strequal(p, "sub"))
719 return LDAP_SCOPE_SUBTREE;
720 if(strequal( p, "subtree"))
721 return LDAP_SCOPE_SUBTREE;
726 * Split 'str' into strings separated by commas.
727 * Note: out[] points into 'str'.
729 static bool split_str(char *str, char ***out, size_t *count)
737 s = strchr(str, ',');
740 s = strchr(++s, ',');
743 res = calloc(items, sizeof(char *));
747 for(i = 0, s = strtok_r(str, ",", &lasts); s && i < items;
748 s = strtok_r(NULL, ",", &lasts), i++)
758 * Break apart the pieces of an LDAP URL.
760 * ldap://<hostname>:<port>/<base_dn>?<attributes>?<scope>?<filter>?<ext>
762 * <hostname> already known from 'conn->host.name'.
763 * <port> already known from 'conn->remote_port'.
764 * extract the rest from 'conn->data->state.path+1'. All fields are optional.
766 * ldap://<hostname>:<port>/?<attributes>?<scope>?<filter>
767 * yields ludp->lud_dn = "".
769 * Defined in RFC4516 section 2.
771 static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
773 int rc = LDAP_SUCCESS;
780 !conn->data->state.path ||
781 conn->data->state.path[0] != '/' ||
782 !checkprefix("LDAP", conn->data->change.url))
783 return LDAP_INVALID_SYNTAX;
785 ludp->lud_scope = LDAP_SCOPE_BASE;
786 ludp->lud_port = conn->remote_port;
787 ludp->lud_host = conn->host.name;
789 /* Duplicate the path */
790 p = path = strdup(conn->data->state.path + 1);
792 return LDAP_NO_MEMORY;
794 /* Parse the DN (Distinguished Name) */
803 LDAP_TRACE (("DN '%s'\n", dn));
805 /* Unescape the DN */
806 unescaped = curl_easy_unescape(conn->data, dn, 0, NULL);
813 #if defined(USE_WIN32_LDAP)
814 /* Convert the unescaped string to a tchar */
815 ludp->lud_dn = Curl_convert_UTF8_to_tchar(unescaped);
817 /* Free the unescaped string as we are done with it */
818 Curl_unicodefree(unescaped);
826 ludp->lud_dn = unescaped;
834 /* Parse the attributes. skip "??" */
843 /* Split the string into an array of attributes */
844 if(!split_str(p, &attributes, &count)) {
850 /* Allocate our array (+1 for the NULL entry) */
851 #if defined(USE_WIN32_LDAP)
852 ludp->lud_attrs = calloc(count + 1, sizeof(TCHAR *));
854 ludp->lud_attrs = calloc(count + 1, sizeof(char *));
856 if(!ludp->lud_attrs) {
864 for(i = 0; i < count; i++) {
867 LDAP_TRACE (("attr[%d] '%s'\n", i, attributes[i]));
869 /* Unescape the attribute */
870 unescaped = curl_easy_unescape(conn->data, attributes[i], 0, NULL);
879 #if defined(USE_WIN32_LDAP)
880 /* Convert the unescaped string to a tchar */
881 ludp->lud_attrs[i] = Curl_convert_UTF8_to_tchar(unescaped);
883 /* Free the unescaped string as we are done with it */
884 Curl_unicodefree(unescaped);
886 if(!ludp->lud_attrs[i]) {
894 ludp->lud_attrs[i] = unescaped;
897 ludp->lud_attrs_dups++;
907 /* Parse the scope. skip "??" */
913 ludp->lud_scope = str2scope(p);
914 if(ludp->lud_scope == -1) {
915 rc = LDAP_INVALID_SYNTAX;
919 LDAP_TRACE (("scope %d\n", ludp->lud_scope));
926 /* Parse the filter */
935 LDAP_TRACE (("filter '%s'\n", filter));
937 /* Unescape the filter */
938 unescaped = curl_easy_unescape(conn->data, filter, 0, NULL);
945 #if defined(USE_WIN32_LDAP)
946 /* Convert the unescaped string to a tchar */
947 ludp->lud_filter = Curl_convert_UTF8_to_tchar(unescaped);
949 /* Free the unescaped string as we are done with it */
950 Curl_unicodefree(unescaped);
952 if(!ludp->lud_filter) {
958 ludp->lud_filter = unescaped;
964 rc = LDAP_INVALID_SYNTAX;
975 static int _ldap_url_parse (const struct connectdata *conn,
978 LDAPURLDesc *ludp = calloc(1, sizeof(*ludp));
983 return LDAP_NO_MEMORY;
985 rc = _ldap_url_parse2 (conn, ludp);
986 if(rc != LDAP_SUCCESS) {
987 _ldap_free_urldesc(ludp);
994 static void _ldap_free_urldesc (LDAPURLDesc *ludp)
1002 free(ludp->lud_filter);
1004 if(ludp->lud_attrs) {
1005 for(i = 0; i < ludp->lud_attrs_dups; i++)
1006 free(ludp->lud_attrs[i]);
1007 free(ludp->lud_attrs);
1012 #endif /* !HAVE_LDAP_URL_PARSE */
1013 #endif /* !CURL_DISABLE_LDAP && !USE_OPENLDAP */