mirror of
https://github.com/postgres/postgres.git
synced 2025-10-11 00:03:02 -04:00
libpq: Set LDAP protocol version 3
Some LDAP servers reject the default version 2 protocol. So set version 3 before starting the connection. This matches how the backend LDAP code has worked all along. Co-authored-by: Andrew Jackson <andrewjackson947@gmail.com> Reviewed-by: Pavel Seleznev <pavel.seleznev@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/CAKK5BkHixcivSCA9pfd_eUp7wkLRhvQ6OtGLAYrWC%3Dk7E76LDQ%40mail.gmail.com
This commit is contained in:
parent
b227b0bb4e
commit
5f19d13dfe
@ -5494,6 +5494,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
|
|||||||
*entry;
|
*entry;
|
||||||
struct berval **values;
|
struct berval **values;
|
||||||
LDAP_TIMEVAL time = {PGLDAP_TIMEOUT, 0};
|
LDAP_TIMEVAL time = {PGLDAP_TIMEOUT, 0};
|
||||||
|
int ldapversion = LDAP_VERSION3;
|
||||||
|
|
||||||
if ((url = strdup(purl)) == NULL)
|
if ((url = strdup(purl)) == NULL)
|
||||||
{
|
{
|
||||||
@ -5625,6 +5626,15 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options,
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((rc = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &ldapversion)) != LDAP_SUCCESS)
|
||||||
|
{
|
||||||
|
libpq_append_error(errorMessage, "could not set LDAP protocol version: %s",
|
||||||
|
ldap_err2string(rc));
|
||||||
|
free(url);
|
||||||
|
ldap_unbind(ld);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Perform an explicit anonymous bind.
|
* Perform an explicit anonymous bind.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user