Hello,
i try to bind to an server using the ldap_sals_bind_s function. The Host is not localhost, but is accessible via internet. I'v tested the connection with a java based ldap browser. When i try to do this using my simple c++ program, it fails with error -1.
Here is what the program actually do: //initialize returns success result = ldap_initialize( &ld, host); result = ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, LDAP_VERSION3); //set this option only after successful bind? result = ldap_set_option(ld, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
//the synchronous bind function returns -1 server down result = ldap_sasl_bind_s(ld, root_dn, LDAP_SASL_SIMPLE, &credential, NULL,NULL, &serverReturnedCredentials);
When I use the asynchronous ldap_sals_bind() function, it returns 0 ldap_success. (I`m also able to create a simple socket to this particular server and port). The error -1 comes from the following ldap_result() function. The problem here is that the socket throws a sock_errno 54 (connection reset by peer).
Someone an idea why the connection always will be disturbed?
Thanks for any help
best regards, Max
On Tue, 7 Aug 2012, Max Kunz wrote: ...
Here is what the program actually do: //initialize returns success result = ldap_initialize( &ld, host); result = ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, LDAP_VERSION3);
That "actually" what it does? I'm surprised it doesn't segfault immediately there, given that ldap_set_option() deferences the last argument as pointer. What's the value of 'result' after that?
(If the code is different from what you showed, then "actually" was a lie.)
//set this option only after successful bind? result = ldap_set_option(ld, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
Same problem here.
My conclusion is that the problem is in the real code that you didn't show.
Philip Guenther
openldap-technical@openldap.org