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 http://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 CURL_LDAP_WIN /* 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 */
58 #include <curl/curl.h>
65 #include "curl_ldap.h"
66 #include "curl_memory.h"
67 #include "curl_multibyte.h"
68 #include "curl_base64.h"
72 #define _MPRINTF_REPLACE /* use our functions only */
73 #include <curl/mprintf.h>
77 #ifndef HAVE_LDAP_URL_PARSE
79 /* Use our own implementation. */
84 #if defined(CURL_LDAP_WIN)
92 #if defined(CURL_LDAP_WIN)
98 size_t lud_attrs_dups; /* how many were dup'ed, this field is not in the
99 "real" struct so can only be used in code
100 without HAVE_LDAP_URL_PARSE defined */
104 #define LDAPURLDesc CURL_LDAPURLDesc
106 static int _ldap_url_parse (const struct connectdata *conn,
108 static void _ldap_free_urldesc (LDAPURLDesc *ludp);
110 #undef ldap_free_urldesc
111 #define ldap_free_urldesc _ldap_free_urldesc
115 #define LDAP_TRACE(x) do { \
116 _ldap_trace ("%u: ", __LINE__); \
120 static void _ldap_trace (const char *fmt, ...);
122 #define LDAP_TRACE(x) Curl_nop_stmt
126 static CURLcode Curl_ldap(struct connectdata *conn, bool *done);
129 * LDAP protocol handler.
132 const struct Curl_handler Curl_handler_ldap = {
134 ZERO_NULL, /* setup_connection */
135 Curl_ldap, /* do_it */
136 ZERO_NULL, /* done */
137 ZERO_NULL, /* do_more */
138 ZERO_NULL, /* connect_it */
139 ZERO_NULL, /* connecting */
140 ZERO_NULL, /* doing */
141 ZERO_NULL, /* proto_getsock */
142 ZERO_NULL, /* doing_getsock */
143 ZERO_NULL, /* domore_getsock */
144 ZERO_NULL, /* perform_getsock */
145 ZERO_NULL, /* disconnect */
146 ZERO_NULL, /* readwrite */
147 PORT_LDAP, /* defport */
148 CURLPROTO_LDAP, /* protocol */
149 PROTOPT_NONE /* flags */
154 * LDAPS protocol handler.
157 const struct Curl_handler Curl_handler_ldaps = {
158 "LDAPS", /* scheme */
159 ZERO_NULL, /* setup_connection */
160 Curl_ldap, /* do_it */
161 ZERO_NULL, /* done */
162 ZERO_NULL, /* do_more */
163 ZERO_NULL, /* connect_it */
164 ZERO_NULL, /* connecting */
165 ZERO_NULL, /* doing */
166 ZERO_NULL, /* proto_getsock */
167 ZERO_NULL, /* doing_getsock */
168 ZERO_NULL, /* domore_getsock */
169 ZERO_NULL, /* perform_getsock */
170 ZERO_NULL, /* disconnect */
171 ZERO_NULL, /* readwrite */
172 PORT_LDAPS, /* defport */
173 CURLPROTO_LDAPS, /* protocol */
174 PROTOPT_SSL /* flags */
179 static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
181 CURLcode result = CURLE_OK;
184 LDAPURLDesc *ludp = NULL;
185 LDAPMessage *ldapmsg = NULL;
186 LDAPMessage *entryIterator;
188 struct SessionHandle *data=conn->data;
189 int ldap_proto = LDAP_VERSION3;
191 char *val_b64 = NULL;
192 size_t val_b64_sz = 0;
193 curl_off_t dlsize = 0;
194 #ifdef LDAP_OPT_NETWORK_TIMEOUT
195 struct timeval ldap_timeout = {10,0}; /* 10 sec connection/search timeout */
197 #if defined(CURL_LDAP_WIN)
200 TCHAR *passwd = NULL;
207 *done = TRUE; /* unconditionally */
208 infof(data, "LDAP local: LDAP Vendor = %s ; LDAP Version = %d\n",
209 LDAP_VENDOR_NAME, LDAP_VENDOR_VERSION);
210 infof(data, "LDAP local: %s\n", data->change.url);
212 #ifdef HAVE_LDAP_URL_PARSE
213 rc = ldap_url_parse(data->change.url, &ludp);
215 rc = _ldap_url_parse(conn, &ludp);
218 failf(data, "LDAP local: %s", ldap_err2string(rc));
219 result = CURLE_LDAP_INVALID_URL;
223 /* Get the URL scheme ( either ldap or ldaps ) */
224 if(conn->given->flags & PROTOPT_SSL)
226 infof(data, "LDAP local: trying to establish %s connection\n",
227 ldap_ssl ? "encrypted" : "cleartext");
229 #if defined(CURL_LDAP_WIN)
230 host = Curl_convert_UTF8_to_tchar(conn->host.name);
232 result = CURLE_OUT_OF_MEMORY;
237 if(conn->bits.user_passwd) {
238 user = Curl_convert_UTF8_to_tchar(conn->user);
239 passwd = Curl_convert_UTF8_to_tchar(conn->passwd);
240 if(!user || !passwd) {
241 result = CURLE_OUT_OF_MEMORY;
247 host = conn->host.name;
249 if(conn->bits.user_passwd) {
251 passwd = conn->passwd;
255 #ifdef LDAP_OPT_NETWORK_TIMEOUT
256 ldap_set_option(NULL, LDAP_OPT_NETWORK_TIMEOUT, &ldap_timeout);
258 ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
263 /* Win32 LDAP SDK doesn't support insecure mode without CA! */
264 server = ldap_sslinit(host, (int)conn->port, 1);
265 ldap_set_option(server, LDAP_OPT_SSL, LDAP_OPT_ON);
268 char* ldap_ca = data->set.str[STRING_SSL_CAFILE];
269 #if defined(CURL_HAS_NOVELL_LDAPSDK)
270 rc = ldapssl_client_init(NULL, NULL);
271 if(rc != LDAP_SUCCESS) {
272 failf(data, "LDAP local: ldapssl_client_init %s", ldap_err2string(rc));
273 result = CURLE_SSL_CERTPROBLEM;
276 if(data->set.ssl.verifypeer) {
277 /* Novell SDK supports DER or BASE64 files. */
278 int cert_type = LDAPSSL_CERT_FILETYPE_B64;
279 if((data->set.str[STRING_CERT_TYPE]) &&
280 (Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "DER")))
281 cert_type = LDAPSSL_CERT_FILETYPE_DER;
283 failf(data, "LDAP local: ERROR %s CA cert not set!",
284 (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"));
285 result = CURLE_SSL_CERTPROBLEM;
288 infof(data, "LDAP local: using %s CA cert '%s'\n",
289 (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
291 rc = ldapssl_add_trusted_cert(ldap_ca, cert_type);
292 if(rc != LDAP_SUCCESS) {
293 failf(data, "LDAP local: ERROR setting %s CA cert: %s",
294 (cert_type == LDAPSSL_CERT_FILETYPE_DER ? "DER" : "PEM"),
295 ldap_err2string(rc));
296 result = CURLE_SSL_CERTPROBLEM;
299 ldap_option = LDAPSSL_VERIFY_SERVER;
302 ldap_option = LDAPSSL_VERIFY_NONE;
303 rc = ldapssl_set_verify_mode(ldap_option);
304 if(rc != LDAP_SUCCESS) {
305 failf(data, "LDAP local: ERROR setting cert verify mode: %s",
306 ldap_err2string(rc));
307 result = CURLE_SSL_CERTPROBLEM;
310 server = ldapssl_init(host, (int)conn->port, 1);
312 failf(data, "LDAP local: Cannot connect to %s:%ld",
313 conn->host.dispname, conn->port);
314 result = CURLE_COULDNT_CONNECT;
317 #elif defined(LDAP_OPT_X_TLS)
318 if(data->set.ssl.verifypeer) {
319 /* OpenLDAP SDK supports BASE64 files. */
320 if((data->set.str[STRING_CERT_TYPE]) &&
321 (!Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "PEM"))) {
322 failf(data, "LDAP local: ERROR OpenLDAP only supports PEM cert-type!");
323 result = CURLE_SSL_CERTPROBLEM;
327 failf(data, "LDAP local: ERROR PEM CA cert not set!");
328 result = CURLE_SSL_CERTPROBLEM;
331 infof(data, "LDAP local: using PEM CA cert: %s\n", ldap_ca);
332 rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, ldap_ca);
333 if(rc != LDAP_SUCCESS) {
334 failf(data, "LDAP local: ERROR setting PEM CA cert: %s",
335 ldap_err2string(rc));
336 result = CURLE_SSL_CERTPROBLEM;
339 ldap_option = LDAP_OPT_X_TLS_DEMAND;
342 ldap_option = LDAP_OPT_X_TLS_NEVER;
344 rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
345 if(rc != LDAP_SUCCESS) {
346 failf(data, "LDAP local: ERROR setting cert verify mode: %s",
347 ldap_err2string(rc));
348 result = CURLE_SSL_CERTPROBLEM;
351 server = ldap_init(host, (int)conn->port);
353 failf(data, "LDAP local: Cannot connect to %s:%ld",
354 conn->host.dispname, conn->port);
355 result = CURLE_COULDNT_CONNECT;
358 ldap_option = LDAP_OPT_X_TLS_HARD;
359 rc = ldap_set_option(server, LDAP_OPT_X_TLS, &ldap_option);
360 if(rc != LDAP_SUCCESS) {
361 failf(data, "LDAP local: ERROR setting SSL/TLS mode: %s",
362 ldap_err2string(rc));
363 result = CURLE_SSL_CERTPROBLEM;
367 rc = ldap_start_tls_s(server, NULL, NULL);
368 if(rc != LDAP_SUCCESS) {
369 failf(data, "LDAP local: ERROR starting SSL/TLS mode: %s",
370 ldap_err2string(rc));
371 result = CURLE_SSL_CERTPROBLEM;
376 /* we should probably never come up to here since configure
377 should check in first place if we can support LDAP SSL/TLS */
378 failf(data, "LDAP local: SSL/TLS not supported with this version "
379 "of the OpenLDAP toolkit\n");
380 result = CURLE_SSL_CERTPROBLEM;
384 #endif /* CURL_LDAP_USE_SSL */
387 server = ldap_init(host, (int)conn->port);
389 failf(data, "LDAP local: Cannot connect to %s:%ld",
390 conn->host.dispname, conn->port);
391 result = CURLE_COULDNT_CONNECT;
396 ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
399 rc = ldap_simple_bind_s(server, user, passwd);
400 if(!ldap_ssl && rc != 0) {
401 ldap_proto = LDAP_VERSION2;
402 ldap_set_option(server, LDAP_OPT_PROTOCOL_VERSION, &ldap_proto);
403 rc = ldap_simple_bind_s(server, user, passwd);
406 failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
407 result = CURLE_LDAP_CANNOT_BIND;
411 rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
412 ludp->lud_filter, ludp->lud_attrs, 0, &ldapmsg);
414 if(rc != 0 && rc != LDAP_SIZELIMIT_EXCEEDED) {
415 failf(data, "LDAP remote: %s", ldap_err2string(rc));
416 result = CURLE_LDAP_SEARCH_FAILED;
420 for(num = 0, entryIterator = ldap_first_entry(server, ldapmsg);
422 entryIterator = ldap_next_entry(server, entryIterator), num++) {
423 BerElement *ber = NULL;
424 #if defined(CURL_LDAP_WIN)
427 char *attribute; /*! suspicious that this isn't 'const' */
431 /* Get the DN and write it to the client */
435 #if defined(CURL_LDAP_WIN)
436 TCHAR *dn = ldap_get_dn(server, entryIterator);
437 name = Curl_convert_tchar_to_UTF8(dn);
441 result = CURLE_OUT_OF_MEMORY;
446 char *dn = name = ldap_get_dn(server, entryIterator);
448 name_len = strlen(name);
450 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"DN: ", 4);
452 #if defined(CURL_LDAP_WIN)
453 Curl_unicodefree(name);
460 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *) name,
463 #if defined(CURL_LDAP_WIN)
464 Curl_unicodefree(name);
471 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
473 #if defined(CURL_LDAP_WIN)
474 Curl_unicodefree(name);
481 dlsize += name_len + 5;
483 #if defined(CURL_LDAP_WIN)
484 Curl_unicodefree(name);
489 /* Get the attributes and write them to the client */
490 for(attribute = ldap_first_attribute(server, entryIterator, &ber);
492 attribute = ldap_next_attribute(server, entryIterator, ber)) {
495 #if defined(CURL_LDAP_WIN)
496 char *attr = Curl_convert_tchar_to_UTF8(attribute);
501 result = CURLE_OUT_OF_MEMORY;
506 char *attr = attribute;
508 attr_len = strlen(attr);
510 vals = ldap_get_values_len(server, entryIterator, attribute);
512 for(i = 0; (vals[i] != NULL); i++) {
513 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
515 ldap_value_free_len(vals);
516 #if defined(CURL_LDAP_WIN)
517 Curl_unicodefree(attr);
519 ldap_memfree(attribute);
526 result = Curl_client_write(conn, CLIENTWRITE_BODY,
527 (char *) attr, attr_len);
529 ldap_value_free_len(vals);
530 #if defined(CURL_LDAP_WIN)
531 Curl_unicodefree(attr);
533 ldap_memfree(attribute);
540 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
542 ldap_value_free_len(vals);
543 #if defined(CURL_LDAP_WIN)
544 Curl_unicodefree(attr);
546 ldap_memfree(attribute);
553 dlsize += attr_len + 3;
556 (strcmp(";binary", (char *) attr + (attr_len - 7)) == 0)) {
557 /* Binary attribute, encode to base64. */
558 result = Curl_base64_encode(data,
564 ldap_value_free_len(vals);
565 #if defined(CURL_LDAP_WIN)
566 Curl_unicodefree(attr);
568 ldap_memfree(attribute);
576 result = Curl_client_write(conn, CLIENTWRITE_BODY, val_b64,
580 ldap_value_free_len(vals);
581 #if defined(CURL_LDAP_WIN)
582 Curl_unicodefree(attr);
584 ldap_memfree(attribute);
591 dlsize += val_b64_sz;
595 result = Curl_client_write(conn, CLIENTWRITE_BODY, vals[i]->bv_val,
598 ldap_value_free_len(vals);
599 #if defined(CURL_LDAP_WIN)
600 Curl_unicodefree(attr);
602 ldap_memfree(attribute);
609 dlsize += vals[i]->bv_len;
612 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
614 ldap_value_free_len(vals);
615 #if defined(CURL_LDAP_WIN)
616 Curl_unicodefree(attr);
618 ldap_memfree(attribute);
628 /* Free memory used to store values */
629 ldap_value_free_len(vals);
632 /* Free the attribute as we are done with it */
633 #if defined(CURL_LDAP_WIN)
634 Curl_unicodefree(attr);
636 ldap_memfree(attribute);
638 result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\n", 1);
642 Curl_pgrsSetDownloadCounter(data, dlsize);
651 ldap_msgfree(ldapmsg);
652 LDAP_TRACE (("Received %d entries\n", num));
654 if(rc == LDAP_SIZELIMIT_EXCEEDED)
655 infof(data, "There are more than %d entries\n", num);
657 ldap_free_urldesc(ludp);
659 ldap_unbind_s(server);
660 #if defined(HAVE_LDAP_SSL) && defined(CURL_HAS_NOVELL_LDAPSDK)
662 ldapssl_client_deinit();
663 #endif /* HAVE_LDAP_SSL && CURL_HAS_NOVELL_LDAPSDK */
665 #if defined(CURL_LDAP_WIN)
666 Curl_unicodefree(passwd);
667 Curl_unicodefree(user);
668 Curl_unicodefree(host);
671 /* no data to transfer */
672 Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
673 connclose(conn, "LDAP connection always disable re-use");
679 static void _ldap_trace (const char *fmt, ...)
681 static int do_trace = -1;
685 const char *env = getenv("CURL_TRACE");
686 do_trace = (env && strtol(env, NULL, 10) > 0);
691 va_start (args, fmt);
692 vfprintf (stderr, fmt, args);
697 #ifndef HAVE_LDAP_URL_PARSE
700 * Return scope-value for a scope-string.
702 static int str2scope (const char *p)
704 if(strequal(p, "one"))
705 return LDAP_SCOPE_ONELEVEL;
706 if(strequal(p, "onetree"))
707 return LDAP_SCOPE_ONELEVEL;
708 if(strequal(p, "base"))
709 return LDAP_SCOPE_BASE;
710 if(strequal(p, "sub"))
711 return LDAP_SCOPE_SUBTREE;
712 if(strequal( p, "subtree"))
713 return LDAP_SCOPE_SUBTREE;
718 * Split 'str' into strings separated by commas.
719 * Note: out[] points into 'str'.
721 static bool split_str(char *str, char ***out, size_t *count)
729 s = strchr(str, ',');
732 s = strchr(++s, ',');
735 res = calloc(items, sizeof(char *));
739 for(i = 0, s = strtok_r(str, ",", &lasts); s && i < items;
740 s = strtok_r(NULL, ",", &lasts), i++)
750 * Break apart the pieces of an LDAP URL.
752 * ldap://<hostname>:<port>/<base_dn>?<attributes>?<scope>?<filter>?<ext>
754 * <hostname> already known from 'conn->host.name'.
755 * <port> already known from 'conn->remote_port'.
756 * extract the rest from 'conn->data->state.path+1'. All fields are optional.
758 * ldap://<hostname>:<port>/?<attributes>?<scope>?<filter>
759 * yields ludp->lud_dn = "".
761 * Defined in RFC4516 section 2.
763 static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
765 int rc = LDAP_SUCCESS;
772 !conn->data->state.path ||
773 conn->data->state.path[0] != '/' ||
774 !checkprefix("LDAP", conn->data->change.url))
775 return LDAP_INVALID_SYNTAX;
777 ludp->lud_scope = LDAP_SCOPE_BASE;
778 ludp->lud_port = conn->remote_port;
779 ludp->lud_host = conn->host.name;
781 /* Duplicate the path */
782 p = path = strdup(conn->data->state.path + 1);
784 return LDAP_NO_MEMORY;
786 /* Parse the DN (Distinguished Name) */
795 LDAP_TRACE (("DN '%s'\n", dn));
797 /* Unescape the DN */
798 unescaped = curl_easy_unescape(conn->data, dn, 0, NULL);
805 #if defined(CURL_LDAP_WIN)
806 /* Convert the unescaped string to a tchar */
807 ludp->lud_dn = Curl_convert_UTF8_to_tchar(unescaped);
809 /* Free the unescaped string as we are done with it */
810 Curl_unicodefree(unescaped);
818 ludp->lud_dn = unescaped;
826 /* Parse the attributes. skip "??" */
835 /* Split the string into an array of attributes */
836 if(!split_str(p, &attributes, &count)) {
842 /* Allocate our array (+1 for the NULL entry) */
843 #if defined(CURL_LDAP_WIN)
844 ludp->lud_attrs = calloc(count + 1, sizeof(TCHAR *));
846 ludp->lud_attrs = calloc(count + 1, sizeof(char *));
848 if(!ludp->lud_attrs) {
849 Curl_safefree(attributes);
856 for(i = 0; i < count; i++) {
859 LDAP_TRACE (("attr[%d] '%s'\n", i, attributes[i]));
861 /* Unescape the attribute */
862 unescaped = curl_easy_unescape(conn->data, attributes[i], 0, NULL);
864 Curl_safefree(attributes);
871 #if defined(CURL_LDAP_WIN)
872 /* Convert the unescaped string to a tchar */
873 ludp->lud_attrs[i] = Curl_convert_UTF8_to_tchar(unescaped);
875 /* Free the unescaped string as we are done with it */
876 Curl_unicodefree(unescaped);
878 if(!ludp->lud_attrs[i]) {
879 Curl_safefree(attributes);
886 ludp->lud_attrs[i] = unescaped;
889 ludp->lud_attrs_dups++;
892 Curl_safefree(attributes);
899 /* Parse the scope. skip "??" */
905 ludp->lud_scope = str2scope(p);
906 if(ludp->lud_scope == -1) {
907 rc = LDAP_INVALID_SYNTAX;
911 LDAP_TRACE (("scope %d\n", ludp->lud_scope));
918 /* Parse the filter */
927 LDAP_TRACE (("filter '%s'\n", filter));
929 /* Unescape the filter */
930 unescaped = curl_easy_unescape(conn->data, filter, 0, NULL);
937 #if defined(CURL_LDAP_WIN)
938 /* Convert the unescaped string to a tchar */
939 ludp->lud_filter = Curl_convert_UTF8_to_tchar(unescaped);
941 /* Free the unescaped string as we are done with it */
942 Curl_unicodefree(unescaped);
944 if(!ludp->lud_filter) {
950 ludp->lud_filter = unescaped;
956 rc = LDAP_INVALID_SYNTAX;
967 static int _ldap_url_parse (const struct connectdata *conn,
970 LDAPURLDesc *ludp = calloc(1, sizeof(*ludp));
975 return LDAP_NO_MEMORY;
977 rc = _ldap_url_parse2 (conn, ludp);
978 if(rc != LDAP_SUCCESS) {
979 _ldap_free_urldesc(ludp);
986 static void _ldap_free_urldesc (LDAPURLDesc *ludp)
997 free(ludp->lud_filter);
999 if(ludp->lud_attrs) {
1000 for(i = 0; i < ludp->lud_attrs_dups; i++)
1001 free(ludp->lud_attrs[i]);
1002 free(ludp->lud_attrs);
1007 #endif /* !HAVE_LDAP_URL_PARSE */
1008 #endif /* !CURL_DISABLE_LDAP && !USE_OPENLDAP */