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

Re: SDK: ldap_simple_bind gives Protocol error



Stephen writes:
>    /* Bind anonymously to the LDAP server. */
>    rc = ldap_simple_bind_s( ld, NULL, NULL );

I think that still Binds with LDAP version 2, which the server
may be rejecting.  Try to set LDAP version 3 first:
  int protocol = LDAP_VERSION3;
  ldap_set_option( NULL, LDAP_OPT_PROTOCOL_VERSION, &protocol );

>    if ( rc != LDAP_SUCCESS ) {
>      fprintf(stderr, "ldap_simple_bind_s: %s\n", ldap_err2string(rc));
>      return( 1 );
>    }

That only prints a textual representation fo the error code.  It does
not print the diagnosticMessage which the server may have enclosed to
answer your question.  Try ldap_perror(ld, "Bind failed");

ldap_perror is deprecated, but it's by far the simplest way.  An
alternative is ldap_get_option( ld, LDAP_OPT_DIAGNOSTIC_MESSAGE, &msg );
followed by printing and ldap_memfree()ing the message.  Or async Bind,
then print and free the messages from ldap_parse_result().

-- 
Hallvard