X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=clients%2Ftools%2Fldapsearch.c;h=9b349da6b09289d11aa0943742b4933ee13b62f7;hb=78f6d75586381f3cfa0af8a7e3e72e862a76a730;hp=f105ec0438a5b776f36eb7af773a2cbf4b1d64a8;hpb=e97cdfb7a9d13d619f97a62d9070bb4cfb17f64a;p=openldap diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index f105ec0438..9b349da6b0 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -679,8 +679,9 @@ main( int argc, char **argv ) (void) ldap_initialize( &ld, ldapuri ); } - if( ld != NULL ) { - fprintf( stderr, "Could not create LDAP session handle (%d): %s\n", rc ); + if( ld == NULL ) { + fprintf( stderr, "Could not create LDAP session handle (%d): %s\n", + rc, ldap_err2string(rc) ); return EXIT_FAILURE; } @@ -724,9 +725,13 @@ main( int argc, char **argv ) return EXIT_FAILURE; } - if ( use_tls && ldap_start_tls_s( ld, NULL, NULL ) != LDAP_SUCCESS ) { - if ( use_tls > 1 ) { + if ( use_tls ) { + rc = ldap_start_tls_s( ld, NULL, NULL ); + + if ( rc != LDAP_SUCCESS && use_tls > 1 ) { ldap_perror( ld, "ldap_start_tls" ); + fprintf( stderr, "Could not start TLS %d: %s\n", + rc, ldap_err2string( rc ) ); return EXIT_FAILURE; } fprintf( stderr, "WARNING: could not start TLS\n" );