if ((r = ldap_set_option(*ldap, LDAP_OPT_PROTOCOL_VERSION, &ldapversion)) != LDAP_SUCCESS)
{
- ldap_unbind(*ldap);
ereport(LOG,
(errmsg("could not set LDAP protocol version: %s", ldap_err2string(r))));
+ ldap_unbind(*ldap);
return STATUS_ERROR;
}
* should never happen since we import other files from
* wldap32, but check anyway
*/
- ldap_unbind(*ldap);
ereport(LOG,
(errmsg("could not load wldap32.dll")));
+ ldap_unbind(*ldap);
return STATUS_ERROR;
}
_ldap_start_tls_sA = (__ldap_start_tls_sA) GetProcAddress(ldaphandle, "ldap_start_tls_sA");
if (_ldap_start_tls_sA == NULL)
{
- ldap_unbind(*ldap);
ereport(LOG,
(errmsg("could not load function _ldap_start_tls_sA in wldap32.dll"),
errdetail("LDAP over SSL is not supported on this platform.")));
+ ldap_unbind(*ldap);
return STATUS_ERROR;
}
if ((r = _ldap_start_tls_sA(*ldap, NULL, NULL, NULL, NULL)) != LDAP_SUCCESS)
#endif
{
- ldap_unbind(*ldap);
ereport(LOG,
(errmsg("could not start LDAP TLS session: %s", ldap_err2string(r))));
+ ldap_unbind(*ldap);
return STATUS_ERROR;
}
}
{
ereport(LOG,
(errmsg("invalid character in user name for LDAP authentication")));
+ ldap_unbind(ldap);
pfree(passwd);
return STATUS_ERROR;
}
ereport(LOG,
(errmsg("could not perform initial LDAP bind for ldapbinddn \"%s\" on server \"%s\": %s",
port->hba->ldapbinddn, port->hba->ldapserver, ldap_err2string(r))));
+ ldap_unbind(ldap);
pfree(passwd);
return STATUS_ERROR;
}
ereport(LOG,
(errmsg("could not search LDAP for filter \"%s\" on server \"%s\": %s",
filter, port->hba->ldapserver, ldap_err2string(r))));
+ ldap_unbind(ldap);
pfree(passwd);
pfree(filter);
return STATUS_ERROR;
count,
filter, port->hba->ldapserver, count)));
+ ldap_unbind(ldap);
pfree(passwd);
pfree(filter);
ldap_msgfree(search_message);
ereport(LOG,
(errmsg("could not get dn for the first entry matching \"%s\" on server \"%s\": %s",
filter, port->hba->ldapserver, ldap_err2string(error))));
+ ldap_unbind(ldap);
pfree(passwd);
pfree(filter);
ldap_msgfree(search_message);
r = ldap_unbind_s(ldap);
if (r != LDAP_SUCCESS)
{
- int error;
-
- (void) ldap_get_option(ldap, LDAP_OPT_ERROR_NUMBER, &error);
ereport(LOG,
- (errmsg("could not unbind after searching for user \"%s\" on server \"%s\": %s",
- fulluser, port->hba->ldapserver, ldap_err2string(error))));
+ (errmsg("could not unbind after searching for user \"%s\" on server \"%s\"",
+ fulluser, port->hba->ldapserver)));
pfree(passwd);
pfree(fulluser);
return STATUS_ERROR;