}
if (use_tls) {
#ifdef LDAP_OPT_X_TLS
- if (version == LDAP_VERSION3 && ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) {
- fprintf(stderr, "Could not Activate TLS connection\n");
- exit(1);
- } else {
+ if (version != LDAP_VERSION3) {
fprintf(stderr, "TLS requires LDAP version 3\n");
exit(1);
+ } else if(ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) {
+ fprintf(stderr, "Could not Activate TLS connection\n");
+ exit(1);
}
#else
fprintf(stderr, "TLS not supported with your LDAP library\n");
}
if (use_tls) {
#ifdef LDAP_OPT_X_TLS
- if (version == LDAP_VERSION3 && ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) {
+ if (version != LDAP_VERSION3) {
+ fprintf(stderr, "TLS requires LDAP version 3\n");
+ exit(1);
+ } else if (ldap_start_tls_s(ld, NULL, NULL) != LDAP_SUCCESS) {
fprintf(stderr, "Could not Activate TLS connection\n");
ldap_unbind(ld);
ld = NULL;
break;
- } else {
- fprintf(stderr, "TLS requires LDAP version 3\n");
- exit(1);
}
#else
fprintf(stderr, "TLS not supported with your LDAP library\n");