1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, 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 /* The last 3 #include files should be in this order */
80 #include "curl_printf.h"
81 #include "curl_memory.h"
84 #ifndef HAVE_LDAP_URL_PARSE
86 /* Use our own implementation. */
91 #if defined(USE_WIN32_LDAP)
99 #if defined(USE_WIN32_LDAP)
105 size_t lud_attrs_dups; /* how many were dup'ed, this field is not in the
106 "real" struct so can only be used in code
107 without HAVE_LDAP_URL_PARSE defined */
111 #define LDAPURLDesc CURL_LDAPURLDesc
113 static int _ldap_url_parse (const struct connectdata *conn,
115 static void _ldap_free_urldesc (LDAPURLDesc *ludp);
117 #undef ldap_free_urldesc
118 #define ldap_free_urldesc _ldap_free_urldesc
122 #define LDAP_TRACE(x) do { \
123 _ldap_trace ("%u: ", __LINE__); \
127 static void _ldap_trace (const char *fmt, ...);
129 #define LDAP_TRACE(x) Curl_nop_stmt
133 static CURLcode Curl_ldap(struct connectdata *conn, bool *done);
136 * LDAP protocol handler.
139 const struct Curl_handler Curl_handler_ldap = {
141 ZERO_NULL, /* setup_connection */
142 Curl_ldap, /* do_it */
143 ZERO_NULL, /* done */
144 ZERO_NULL, /* do_more */
145 ZERO_NULL, /* connect_it */
146 ZERO_NULL, /* connecting */
147 ZERO_NULL, /* doing */
148 ZERO_NULL, /* proto_getsock */
149 ZERO_NULL, /* doing_getsock */
150 ZERO_NULL, /* domore_getsock */
151 ZERO_NULL, /* perform_getsock */
152 ZERO_NULL, /* disconnect */
153 ZERO_NULL, /* readwrite */
154 PORT_LDAP, /* defport */
155 CURLPROTO_LDAP, /* protocol */
156 PROTOPT_NONE /* flags */
161 * LDAPS protocol handler.
164 const struct Curl_handler Curl_handler_ldaps = {
165 "LDAPS", /* scheme */
166 ZERO_NULL, /* setup_connection */
167 Curl_ldap, /* do_it */
168 ZERO_NULL, /* done */
169 ZERO_NULL, /* do_more */
170 ZERO_NULL, /* connect_it */
171 ZERO_NULL, /* connecting */
172 ZERO_NULL, /* doing */
173 ZERO_NULL, /* proto_getsock */
174 ZERO_NULL, /* doing_getsock */
175 ZERO_NULL, /* domore_getsock */
176 ZERO_NULL, /* perform_getsock */
177 ZERO_NULL, /* disconnect */
178 ZERO_NULL, /* readwrite */
179 PORT_LDAPS, /* defport */
180 CURLPROTO_LDAPS, /* protocol */
181 PROTOPT_SSL /* flags */
186 static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
188 CURLcode result = CURLE_OK;
191 LDAPURLDesc *ludp = NULL;
192 LDAPMessage *ldapmsg = NULL;
193 LDAPMessage *entryIterator;
195 struct Curl_easy *data=conn->data;
196 int ldap_proto = LDAP_VERSION3;
198 char *val_b64 = NULL;
199 size_t val_b64_sz = 0;
200 curl_off_t dlsize = 0;
201 #ifdef LDAP_OPT_NETWORK_TIMEOUT
202 struct timeval ldap_timeout = {10, 0}; /* 10 sec connection/search timeout */
204 #if defined(USE_WIN32_LDAP)
207 TCHAR *passwd = NULL;
214 *done = TRUE; /* unconditionally */
215 infof(data, "LDAP local: LDAP Vendor = %s ; LDAP Version = %d\n",
216 LDAP_VENDOR_NAME, LDAP_VENDOR_VERSION);
217 infof(data, "LDAP local: %s\n", data->change.url);
219 #ifdef HAVE_LDAP_URL_PARSE
220 rc = ldap_url_parse(data->change.url, &ludp);
222 rc = _ldap_url_parse(conn, &ludp);
225 failf(data, "LDAP local: %s", ldap_err2string(rc));
226 result = CURLE_LDAP_INVALID_URL;
230 /* Get the URL scheme (either ldap or ldaps) */
231 if(conn->given->flags & PROTOPT_SSL)
233 infof(data, "LDAP local: trying to establish %s connection\n",
234 ldap_ssl ? "encrypted" : "cleartext");
236 #if defined(USE_WIN32_LDAP)
237 host = Curl_convert_UTF8_to_tchar(conn->host.name);
239 result = CURLE_OUT_OF_MEMORY;
244 if(conn->bits.user_passwd) {
245 user = Curl_convert_UTF8_to_tchar(conn->user);
246 passwd = Curl_convert_UTF8_to_tchar(conn->passwd);
247 if(!user || !passwd) {
248 result = CURLE_OUT_OF_MEMORY;
254 host = conn->host.name;
256 if(conn->bits.user_passwd) {
258 passwd = conn->passwd;
262 #ifdef LDAP_OPT_NETWORK_TIMEOUT
263 ldap_set_option(NULL, LDAP_OPT_NETWORK_TIMEOUT, &ldap_timeout);
265 ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
269 #ifdef USE_WIN32_LDAP
270 /* Win32 LDAP SDK doesn't support insecure mode without CA! */
271 server = ldap_sslinit(host, (int)conn->port, 1);
272 ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON);
275 char* ldap_ca = data->set.str[STRING_SSL_CAFILE];
276 #if defined(CURL_HAS_NOVELL_LDAPSDK)
277 rc = ldapssl_client_init(NULL, NULL);
278 if(rc != LDAP_SUCCESS) {
279 failf(data, "LDAP local: ldapssl_client_init %s", ldap_err2string(rc));
280 result = CURLE_SSL_CERTPROBLEM;
283 if(data->set.ssl.verifypeer) {
284 /* Novell SDK supports DER or BASE64 files. */
285 int cert_type = LDAPSSL_CERT_FILETYPE_B64;
286 if((data->set.str[STRING_CERT_TYPE]) &&
287 (Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "DER")))
288 cert_type = LDAPSSL_CERT_FILETYPE_DER;
290 failf(data, "LDAP local: ERROR %s CA cert not set!",
291 (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"));
292 result = CURLE_SSL_CERTPROBLEM;
295 infof(data, "LDAP local: using %s CA cert '%s'\n",
296 (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
298 rc = ldapssl_add_trusted_cert(ldap_ca, cert_type);
299 if(rc != LDAP_SUCCESS) {
300 failf(data, "LDAP local: ERROR setting %s CA cert: %s",
301 (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
302 ldap_err2string(rc));
303 result = CURLE_SSL_CERTPROBLEM;
306 ldap_option = LDAPSSL_VERIFY_SERVER;
309 ldap_option = LDAPSSL_VERIFY_NONE;
310 rc = ldapssl_set_verify_mode(ldap_option);
311 if(rc != LDAP_SUCCESS) {
312 failf(data, "LDAP local: ERROR setting cert verify mode: %s",
313 ldap_err2string(rc));
314 result = CURLE_SSL_CERTPROBLEM;
317 server = ldapssl_init(host, (int)conn->port, 1);
319 failf(data, "LDAP local: Cannot connect to %s:%ld",
320 conn->host.dispname, conn->port);
321 result = CURLE_COULDNT_CONNECT;
324 #elif defined(LDAP_OPT_X_TLS)
325 if(data->set.ssl.verifypeer) {
326 /* OpenLDAP SDK supports BASE64 files. */
327 if((data->set.str[STRING_CERT_TYPE]) &&
328 (!Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "PEM"))) {
329 failf(data, "LDAP local: ERROR OpenLDAP only supports PEM cert-type!");
330 result = CURLE_SSL_CERTPROBLEM;
334 failf(data, "LDAP local: ERROR PEM CA cert not set!");
335 result = CURLE_SSL_CERTPROBLEM;
338 infof(data, "LDAP local: using PEM CA cert: %s\n", ldap_ca);
339 rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
340 if(rc != LDAP_SUCCESS) {
341 failf(data, "LDAP local: ERROR setting PEM CA cert: %s",
342 ldap_err2string(rc));
343 result = CURLE_SSL_CERTPROBLEM;
346 ldap_option = LDAP_OPT_X_TLS_DEMAND;
349 ldap_option = LDAP_OPT_X_TLS_NEVER;
351 rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
352 if(rc != LDAP_SUCCESS) {
353 failf(data, "LDAP local: ERROR setting cert verify mode: %s",
354 ldap_err2string(rc));
355 result = CURLE_SSL_CERTPROBLEM;
358 server = ldap_init(host, (int)conn->port);
360 failf(data, "LDAP local: Cannot connect to %s:%ld",
361 conn->host.dispname, conn->port);
362 result = CURLE_COULDNT_CONNECT;
365 ldap_option = LDAP_OPT_X_TLS_HARD;
366 rc = ldap_set_option(server, LDAP_OPT_X_TLS, &ldap_option);
367 if(rc != LDAP_SUCCESS) {
368 failf(data, "LDAP local: ERROR setting SSL/TLS mode: %s",
369 ldap_err2string(rc));
370 result = CURLE_SSL_CERTPROBLEM;
374 rc = ldap_start_tls_s(server, NULL, NULL);
375 if(rc != LDAP_SUCCESS) {
376 failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s",
377 ldap_err2string(rc));
378 result = CURLE_SSL_CERTPROBLEM;
383 /* we should probably never come up to here since configure
384 should check in first place if we can support LDAP SSL/TLS */
385 failf(data, "LDAP local: SSL/TLS not supported with this version "
386 "of the OpenLDAP toolkit\n");
387 result = CURLE_SSL_CERTPROBLEM;
391 #endif /* CURL_LDAP_USE_SSL */
394 server = ldap_init(host, (int)conn->port);
396 failf(data, "LDAP local: Cannot connect to %s:%ld",
397 conn->host.dispname, conn->port);
398 result = CURLE_COULDNT_CONNECT;
402 #ifdef USE_WIN32_LDAP
403 ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
406 rc = ldap_simple_bind_s(server, user, passwd);
407 if(!ldap_ssl && rc != 0) {
408 ldap_proto = LDAP_VERSION2;
409 ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
410 rc = ldap_simple_bind_s(server, user, passwd);
413 failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
414 result = CURLE_LDAP_CANNOT_BIND;
418 rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
419 ludp->lud_filter, ludp->lud_attrs, 0, &ldapmsg);
421 if(rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
422 failf(data, "LDAP remote: %s", ldap_err2string(rc));
423 result = CURLE_LDAP_SEARCH_FAILED;
427 for(num = 0, entryIterator = ldap_first_entry(server, ldapmsg);
429 entryIterator = ldap_next_entry(server, entryIterator), num++) {
430 BerElement *ber = NULL;
431 #if defined(USE_WIN32_LDAP)
434 char *attribute; /*! suspicious that this isn't 'const' */
438 /* Get the DN and write it to the client */
442 #if defined(USE_WIN32_LDAP)
443 TCHAR *dn = ldap_get_dn(server, entryIterator);
444 name = Curl_convert_tchar_to_UTF8(dn);
448 result = CURLE_OUT_OF_MEMORY;
453 char *dn = name = ldap_get_dn(server, entryIterator);
455 name_len = strlen(name);
457 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
459 #if defined(USE_WIN32_LDAP)
460 Curl_unicodefree(name);
467 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *) name,
470 #if defined(USE_WIN32_LDAP)
471 Curl_unicodefree(name);
478 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
480 #if defined(USE_WIN32_LDAP)
481 Curl_unicodefree(name);
488 dlsize += name_len + 5;
490 #if defined(USE_WIN32_LDAP)
491 Curl_unicodefree(name);
496 /* Get the attributes and write them to the client */
497 for(attribute = ldap_first_attribute(server, entryIterator, &ber);
499 attribute = ldap_next_attribute(server, entryIterator, ber)) {
502 #if defined(USE_WIN32_LDAP)
503 char *attr = Curl_convert_tchar_to_UTF8(attribute);
508 result = CURLE_OUT_OF_MEMORY;
513 char *attr = attribute;
515 attr_len = strlen(attr);
517 vals = ldap_get_values_len(server, entryIterator, attribute);
519 for(i = 0; (vals[i] != NULL); i++) {
520 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
522 ldap_value_free_len(vals);
523 #if defined(USE_WIN32_LDAP)
524 Curl_unicodefree(attr);
526 ldap_memfree(attribute);
533 result = Curl_client_write(conn, CLIENTWRITE_BODY,
534 (char *) attr, attr_len);
536 ldap_value_free_len(vals);
537 #if defined(USE_WIN32_LDAP)
538 Curl_unicodefree(attr);
540 ldap_memfree(attribute);
547 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
549 ldap_value_free_len(vals);
550 #if defined(USE_WIN32_LDAP)
551 Curl_unicodefree(attr);
553 ldap_memfree(attribute);
560 dlsize += attr_len + 3;
563 (strcmp(";binary", (char *) attr + (attr_len - 7)) == 0)) {
564 /* Binary attribute, encode to base64. */
565 result = Curl_base64_encode(data,
571 ldap_value_free_len(vals);
572 #if defined(USE_WIN32_LDAP)
573 Curl_unicodefree(attr);
575 ldap_memfree(attribute);
583 result = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64,
587 ldap_value_free_len(vals);
588 #if defined(USE_WIN32_LDAP)
589 Curl_unicodefree(attr);
591 ldap_memfree(attribute);
598 dlsize += val_b64_sz;
602 result = Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
605 ldap_value_free_len(vals);
606 #if defined(USE_WIN32_LDAP)
607 Curl_unicodefree(attr);
609 ldap_memfree(attribute);
616 dlsize += vals[i]->bv_len;
619 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
621 ldap_value_free_len(vals);
622 #if defined(USE_WIN32_LDAP)
623 Curl_unicodefree(attr);
625 ldap_memfree(attribute);
635 /* Free memory used to store values */
636 ldap_value_free_len(vals);
639 /* Free the attribute as we are done with it */
640 #if defined(USE_WIN32_LDAP)
641 Curl_unicodefree(attr);
643 ldap_memfree(attribute);
645 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
649 Curl_pgrsSetDownloadCounter(data, dlsize);
658 ldap_msgfree(ldapmsg);
659 LDAP_TRACE (("Received %d entries\n", num));
661 if(rc == LDAP_SIZELIMIT_EXCEEDED)
662 infof(data, "There are more than %d entries\n", num);
664 ldap_free_urldesc(ludp);
666 ldap_unbind_s(server);
667 #if defined(HAVE_LDAP_SSL) && defined(CURL_HAS_NOVELL_LDAPSDK)
669 ldapssl_client_deinit();
670 #endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
672 #if defined(USE_WIN32_LDAP)
673 Curl_unicodefree(passwd);
674 Curl_unicodefree(user);
675 Curl_unicodefree(host);
678 /* no data to transfer */
679 Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
680 connclose(conn, "LDAP connection always disable re-use");
686 static void _ldap_trace (const char *fmt, ...)
688 static int do_trace = -1;
692 const char *env = getenv("CURL_TRACE");
693 do_trace = (env && strtol(env, NULL, 10) > 0);
698 va_start (args, fmt);
699 vfprintf (stderr, fmt, args);
704 #ifndef HAVE_LDAP_URL_PARSE
707 * Return scope-value for a scope-string.
709 static int str2scope (const char *p)
711 if(strequal(p, "one"))
712 return LDAP_SCOPE_ONELEVEL;
713 if(strequal(p, "onetree"))
714 return LDAP_SCOPE_ONELEVEL;
715 if(strequal(p, "base"))
716 return LDAP_SCOPE_BASE;
717 if(strequal(p, "sub"))
718 return LDAP_SCOPE_SUBTREE;
719 if(strequal(p, "subtree"))
720 return LDAP_SCOPE_SUBTREE;
725 * Split 'str' into strings separated by commas.
726 * Note: out[] points into 'str'.
728 static bool split_str(char *str, char ***out, size_t *count)
736 s = strchr(str, ',');
739 s = strchr(++s, ',');
742 res = calloc(items, sizeof(char *));
746 for(i = 0, s = strtok_r(str, ",", &lasts); s && i < items;
747 s = strtok_r(NULL, ",", &lasts), i++)
757 * Break apart the pieces of an LDAP URL.
759 * ldap://<hostname>:<port>/<base_dn>?<attributes>?<scope>?<filter>?<ext>
761 * <hostname> already known from 'conn->host.name'.
762 * <port> already known from 'conn->remote_port'.
763 * extract the rest from 'conn->data->state.path+1'. All fields are optional.
765 * ldap://<hostname>:<port>/?<attributes>?<scope>?<filter>
766 * yields ludp->lud_dn = "".
768 * Defined in RFC4516 section 2.
770 static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
772 int rc = LDAP_SUCCESS;
779 !conn->data->state.path ||
780 conn->data->state.path[0] != '/' ||
781 !checkprefix("LDAP", conn->data->change.url))
782 return LDAP_INVALID_SYNTAX;
784 ludp->lud_scope = LDAP_SCOPE_BASE;
785 ludp->lud_port = conn->remote_port;
786 ludp->lud_host = conn->host.name;
788 /* Duplicate the path */
789 p = path = strdup(conn->data->state.path + 1);
791 return LDAP_NO_MEMORY;
793 /* Parse the DN (Distinguished Name) */
802 LDAP_TRACE (("DN '%s'\n", dn));
804 /* Unescape the DN */
805 unescaped = curl_easy_unescape(conn->data, dn, 0, NULL);
812 #if defined(USE_WIN32_LDAP)
813 /* Convert the unescaped string to a tchar */
814 ludp->lud_dn = Curl_convert_UTF8_to_tchar(unescaped);
816 /* Free the unescaped string as we are done with it */
817 Curl_unicodefree(unescaped);
825 ludp->lud_dn = unescaped;
833 /* Parse the attributes. skip "??" */
842 /* Split the string into an array of attributes */
843 if(!split_str(p, &attributes, &count)) {
849 /* Allocate our array (+1 for the NULL entry) */
850 #if defined(USE_WIN32_LDAP)
851 ludp->lud_attrs = calloc(count + 1, sizeof(TCHAR *));
853 ludp->lud_attrs = calloc(count + 1, sizeof(char *));
855 if(!ludp->lud_attrs) {
863 for(i = 0; i < count; i++) {
866 LDAP_TRACE (("attr[%d] '%s'\n", i, attributes[i]));
868 /* Unescape the attribute */
869 unescaped = curl_easy_unescape(conn->data, attributes[i], 0, NULL);
878 #if defined(USE_WIN32_LDAP)
879 /* Convert the unescaped string to a tchar */
880 ludp->lud_attrs[i] = Curl_convert_UTF8_to_tchar(unescaped);
882 /* Free the unescaped string as we are done with it */
883 Curl_unicodefree(unescaped);
885 if(!ludp->lud_attrs[i]) {
893 ludp->lud_attrs[i] = unescaped;
896 ludp->lud_attrs_dups++;
906 /* Parse the scope. skip "??" */
912 ludp->lud_scope = str2scope(p);
913 if(ludp->lud_scope == -1) {
914 rc = LDAP_INVALID_SYNTAX;
918 LDAP_TRACE (("scope %d\n", ludp->lud_scope));
925 /* Parse the filter */
934 LDAP_TRACE (("filter '%s'\n", filter));
936 /* Unescape the filter */
937 unescaped = curl_easy_unescape(conn->data, filter, 0, NULL);
944 #if defined(USE_WIN32_LDAP)
945 /* Convert the unescaped string to a tchar */
946 ludp->lud_filter = Curl_convert_UTF8_to_tchar(unescaped);
948 /* Free the unescaped string as we are done with it */
949 Curl_unicodefree(unescaped);
951 if(!ludp->lud_filter) {
957 ludp->lud_filter = unescaped;
963 rc = LDAP_INVALID_SYNTAX;
974 static int _ldap_url_parse (const struct connectdata *conn,
977 LDAPURLDesc *ludp = calloc(1, sizeof(*ludp));
982 return LDAP_NO_MEMORY;
984 rc = _ldap_url_parse2 (conn, ludp);
985 if(rc != LDAP_SUCCESS) {
986 _ldap_free_urldesc(ludp);
993 static void _ldap_free_urldesc (LDAPURLDesc *ludp)
1001 free(ludp->lud_filter);
1003 if(ludp->lud_attrs) {
1004 for(i = 0; i < ludp->lud_attrs_dups; i++)
1005 free(ludp->lud_attrs[i]);
1006 free(ludp->lud_attrs);
1011 #endif /* !HAVE_LDAP_URL_PARSE */
1012 #endif /* !CURL_DISABLE_LDAP && !USE_OPENLDAP */