#endif
+#ifdef LDAP_API_FEATURE_X_OPENLDAP
+#if LDAP_VENDOR_VERSION > 194
+#define HAS_URI_SUPPORT 1
+#endif
+#endif
+
static LDAP *
open_ldap_connection(const char *ldapServer, int port)
{
int rc = ldap_initialize(&ld, ldapServer);
if (rc != LDAP_SUCCESS) {
fprintf(stderr, "\nUnable to connect to LDAPURI:%s\n", ldapServer);
- break;
+ exit(1);
}
} else
#endif
squid_ldap_set_timelimit(ld, timelimit);
squid_ldap_set_referrals(ld, !noreferrals);
squid_ldap_set_aliasderef(ld, aliasderef);
+ return ld;
}
-#ifdef LDAP_API_FEATURE_X_OPENLDAP
-#if LDAP_VENDOR_VERSION > 194
-#define HAS_URI_SUPPORT 1
-#endif
-#endif
-
int
main(int argc, char **argv)
{
case 'z':
case 'Z':
case 'd':
+ case 'O':
break;
default:
if (strlen(argv[1]) > 2) {
break;
case 'O':
bind_once = !bind_once;
+ break;
case 'p':
port = atoi(value);
break;
}
rfc1738_unescape(user);
rfc1738_unescape(passwd);
- tryagain = 1;
+ tryagain = (ld != NULL);
recover:
if (ld == NULL && persistent)
ld = open_ldap_connection(ldapServer, port);
snprintf(dn, sizeof(dn), "%s", userdn);
squid_ldap_memfree(userdn);
- if (ret == 0 && (!bind_once || passwdattr)) {
+ if (ret == 0 && (!binddn || !bind_once || passwdattr)) {
/* Reuse the search connection for comparing the user password attribute */
bind_ld = search_ld;
search_ld = NULL;
ldap_msgfree(res);
res = NULL;
}
- if (search_ld != persistent_ld) {
+ if (search_ld && search_ld != persistent_ld) {
ldap_unbind(search_ld);
search_ld = NULL;
}
ldap_unbind(bind_ld);
bind_ld = NULL;
}
- return 0;
+ return ret;
}
int