aboutsummaryrefslogtreecommitdiff
path: root/lib/ldap.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ldap.c')
-rw-r--r--lib/ldap.c73
1 files changed, 36 insertions, 37 deletions
diff --git a/lib/ldap.c b/lib/ldap.c
index 3f067230f..69667fdf8 100644
--- a/lib/ldap.c
+++ b/lib/ldap.c
@@ -46,7 +46,8 @@
#ifdef CURL_LDAP_WIN /* Use Windows LDAP implementation. */
# include <winldap.h>
# ifndef LDAP_VENDOR_NAME
-# error Your Platform SDK is NOT sufficient for LDAP support! Update your Platform SDK, or disable LDAP support!
+# error Your Platform SDK is NOT sufficient for LDAP support! \
+ Update your Platform SDK, or disable LDAP support!
# else
# include <winber.h>
# endif
@@ -255,9 +256,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
goto quit;
}
ldap_option = LDAPSSL_VERIFY_SERVER;
- } else {
- ldap_option = LDAPSSL_VERIFY_NONE;
}
+ else
+ ldap_option = LDAPSSL_VERIFY_NONE;
rc = ldapssl_set_verify_mode(ldap_option);
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting cert verify mode: %s",
@@ -277,7 +278,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
/* OpenLDAP SDK supports BASE64 files. */
if((data->set.str[STRING_CERT_TYPE]) &&
(!Curl_raw_equal(data->set.str[STRING_CERT_TYPE], "PEM"))) {
- failf(data, "LDAP local: ERROR OpenLDAP does only support PEM cert-type!");
+ failf(data, "LDAP local: ERROR OpenLDAP only supports PEM cert-type!");
status = CURLE_SSL_CERTPROBLEM;
goto quit;
}
@@ -295,9 +296,10 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
goto quit;
}
ldap_option = LDAP_OPT_X_TLS_DEMAND;
- } else {
- ldap_option = LDAP_OPT_X_TLS_NEVER;
}
+ else
+ ldap_option = LDAP_OPT_X_TLS_NEVER;
+
rc = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT, &ldap_option);
if(rc != LDAP_SUCCESS) {
failf(data, "LDAP local: ERROR setting cert verify mode: %s",
@@ -339,7 +341,8 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
#endif
#endif
#endif /* CURL_LDAP_USE_SSL */
- } else {
+ }
+ else {
server = ldap_init(conn->host.name, (int)conn->port);
if(server == NULL) {
failf(data, "LDAP local: Cannot connect to %s:%hu",
@@ -363,9 +366,9 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
conn->bits.user_passwd ? conn->passwd : NULL);
}
if(rc != 0) {
- failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
- status = CURLE_LDAP_CANNOT_BIND;
- goto quit;
+ failf(data, "LDAP local: ldap_simple_bind_s %s", ldap_err2string(rc));
+ status = CURLE_LDAP_CANNOT_BIND;
+ goto quit;
}
rc = ldap_search_s(server, ludp->lud_dn, ludp->lud_scope,
@@ -379,8 +382,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
for(num = 0, entryIterator = ldap_first_entry(server, result);
entryIterator;
- entryIterator = ldap_next_entry(server, entryIterator), num++)
- {
+ entryIterator = ldap_next_entry(server, entryIterator), num++) {
BerElement *ber = NULL;
char *attribute; /*! suspicious that this isn't 'const' */
char *dn = ldap_get_dn(server, entryIterator);
@@ -392,16 +394,13 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
dlsize += strlen(dn)+5;
- for (attribute = ldap_first_attribute(server, entryIterator, &ber);
- attribute;
- attribute = ldap_next_attribute(server, entryIterator, ber))
- {
+ for(attribute = ldap_first_attribute(server, entryIterator, &ber);
+ attribute;
+ attribute = ldap_next_attribute(server, entryIterator, ber)) {
BerValue **vals = ldap_get_values_len(server, entryIterator, attribute);
- if(vals != NULL)
- {
- for (i = 0; (vals[i] != NULL); i++)
- {
+ if(vals != NULL) {
+ for(i = 0; (vals[i] != NULL); i++) {
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)"\t", 1);
Curl_client_write(conn, CLIENTWRITE_BODY, (char *) attribute, 0);
Curl_client_write(conn, CLIENTWRITE_BODY, (char *)": ", 2);
@@ -515,15 +514,15 @@ static char **split_str (char *str)
char **res, *lasts, *s;
int i;
- for (i = 2, s = strchr(str,','); s; i++)
- s = strchr(++s,',');
+ for(i = 2, s = strchr(str,','); s; i++)
+ s = strchr(++s,',');
res = calloc(i, sizeof(char*));
if(!res)
return NULL;
- for (i = 0, s = strtok_r(str, ",", &lasts); s;
- s = strtok_r(NULL, ",", &lasts), i++)
+ for(i = 0, s = strtok_r(str, ",", &lasts); s;
+ s = strtok_r(NULL, ",", &lasts), i++)
res[i] = s;
return res;
}
@@ -541,16 +540,16 @@ static bool unescape_elements (void *data, LDAPURLDesc *ludp)
return (FALSE);
}
- for (i = 0; ludp->lud_attrs && ludp->lud_attrs[i]; i++) {
+ for(i = 0; ludp->lud_attrs && ludp->lud_attrs[i]; i++) {
ludp->lud_attrs[i] = curl_easy_unescape(data, ludp->lud_attrs[i], 0, NULL);
if(!ludp->lud_attrs[i])
- return (FALSE);
+ return (FALSE);
}
- for (i = 0; ludp->lud_exts && ludp->lud_exts[i]; i++) {
+ for(i = 0; ludp->lud_exts && ludp->lud_exts[i]; i++) {
ludp->lud_exts[i] = curl_easy_unescape(data, ludp->lud_exts[i], 0, NULL);
if(!ludp->lud_exts[i])
- return (FALSE);
+ return (FALSE);
}
if(ludp->lud_dn) {
@@ -620,7 +619,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
if(!ludp->lud_attrs)
return LDAP_NO_MEMORY;
- for (i = 0; ludp->lud_attrs[i]; i++)
+ for(i = 0; ludp->lud_attrs[i]; i++)
LDAP_TRACE (("attr[%d] '%s'\n", i, ludp->lud_attrs[i]));
}
@@ -666,7 +665,7 @@ static int _ldap_url_parse2 (const struct connectdata *conn, LDAPURLDesc *ludp)
if(!ludp->lud_exts)
return LDAP_NO_MEMORY;
- for (i = 0; ludp->lud_exts[i]; i++)
+ for(i = 0; ludp->lud_exts[i]; i++)
LDAP_TRACE (("exts[%d] '%s'\n", i, ludp->lud_exts[i]));
success:
@@ -699,23 +698,23 @@ static void _ldap_free_urldesc (LDAPURLDesc *ludp)
int i;
if(!ludp)
- return;
+ return;
if(ludp->lud_dn)
- free(ludp->lud_dn);
+ free(ludp->lud_dn);
if(ludp->lud_filter)
- free(ludp->lud_filter);
+ free(ludp->lud_filter);
if(ludp->lud_attrs) {
- for (i = 0; ludp->lud_attrs[i]; i++)
- free(ludp->lud_attrs[i]);
+ for(i = 0; ludp->lud_attrs[i]; i++)
+ free(ludp->lud_attrs[i]);
free(ludp->lud_attrs);
}
if(ludp->lud_exts) {
- for (i = 0; ludp->lud_exts[i]; i++)
- free(ludp->lud_exts[i]);
+ for(i = 0; ludp->lud_exts[i]; i++)
+ free(ludp->lud_exts[i]);
free(ludp->lud_exts);
}
free (ludp);