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

Re: ldap_url_search fails when URL does not specify host (ldap:///) (ITS#843)



I fixed this in HEAD and OPENLDAP_REL_ENG_2 by having ldap_url_search()
to ignore the hostport and to use the default session associated with
the handle.  Please test.

Kurt

At 04:10 PM 10/17/00 +0000, B.Candler@pobox.com wrote:
>Full_Name: Brian Candler
>Version: 2.0.6
>OS: FreeBSD-4.1
>URL: ftp://ftp.openldap.org/incoming/
>Submission from: (NULL) (212.74.96.2)
>
>
>If you explicitly open a connection to a particular host, but then give a URL
>without a host to ldap_url_search, the search fails (error 81,
>LDAP_SERVER_DOWN)
>
>Demonstration: the program below fails with the first version of #define URL,
>but works with the second version of #define URL.
>
>------------------------------------------------------------------
>#include <stdio.h>
>#include <ldap.h>
>
>#define HOST "10.0.0.1"
>#define URL  "ldap:///o=whatever,c=GB??sub?(objectclass=*)"
>/* #define URL  "ldap://10.0.0.1/o=whatever,c=GB??sub?(objectclass=*)" */
>
>int main(void)
>{
>  LDAP *ld = ldap_open(HOST, 389);
>  LDAPMessage *result;
>  int r1, r2;
>  int errorno;
>
>  r1 = ldap_url_search(ld, URL, 0);
>  if (r1 == -1) {
>    char *error;
>    ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &error);
>    fprintf(stderr, "Error in ldap_url_search: %s\n", error?error:"NULL");
>    ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &errorno);
>    fprintf(stderr, "Error in ldap_url_search: %d\n", errorno);
>    return 1;
>  }
>  
>  r2 = ldap_result(ld, LDAP_RES_ANY, 1, NULL, &result);
>  if (r2 == -1) {
>    char *error;
>    ldap_get_option(ld, LDAP_OPT_ERROR_STRING, &error);
>    fprintf(stderr, "Error in ldap_result: %s\n", error);
>    return 1;
>  }
>  return 0;
>}
>------------------------------------------------------------------
>Gives:
>
>Error in ldap_url_search: NULL
>Error in ldap_url_search: 81
>
>Possibly connected: ldap_url_parse now seems to return an
>empty string, rather than a null pointer, in lud_host for URLs without
>explicit hosts.