...
 
Commits (3)
0.69.1
2019-07-23 Sam Varshavchik <mrsam@courier-mta.com>
* authldaplib.cpp (ldapopen): Make sure that we rebind if we reconnect,
if so configured.
2018-10-18 Sam Varshavchik <mrsam@courier-mta.com>
* authldaplib.cpp: Fix handling of LDAP configurations that use the
......
......@@ -54,8 +54,9 @@ class ldap_connection {
public:
LDAP *connection;
bool bound;
ldap_connection() : connection(0) {}
ldap_connection() : connection(0), bound(false) {}
~ldap_connection() { disconnect(); }
bool connected() const { return connection != 0; }
......@@ -81,6 +82,19 @@ public:
bool bind(const std::string &userid,
const std::string &password)
{
if (do_bind(userid, password))
{
bound=true;
return true;
}
return false;
}
private:
bool do_bind(const std::string &userid,
const std::string &password)
{
std::vector<char> buffer(password.begin(), password.end());
struct berval cred;
......@@ -428,6 +442,8 @@ bool ldap_connection::connect()
{
if (connected()) return true;
bound=false;
DPRINTF("authldaplib: connecting to %s", authldaprc.ldap_uri.c_str());
if (ldapconncheck())
......@@ -511,12 +527,13 @@ void ldap_connection::close()
static int ldapopen()
{
if (main_connection.connected()) return 0;
if (!main_connection.connect())
return 1;
if (!main_connection.connected())
{
if (!main_connection.connect())
return 1;
}
if (authldaprc.initbind)
if (authldaprc.initbind && !main_connection.bound)
{
/* Bind to server */
if (courier_authdebug_login_level >= 2)
......@@ -549,7 +566,7 @@ class authldaprc_attributes {
public:
std::map<std::string, std::vector<std::string *>> attributes;
std::map<std::string, std::vector<std::string *> > attributes;
std::string attribute(const char *name,
const char *default_value,
......@@ -570,9 +587,9 @@ class authldaprc_attribute_vector : public std::vector<std::string> {
public:
authldaprc_attribute_vector(const std::map<std::string,
std::vector<std::string *>> &attributes)
std::vector<std::string *> > &attributes)
{
for (std::map<std::string, std::vector<std::string *>>
for (std::map<std::string, std::vector<std::string *> >
::const_iterator
p=attributes.begin(); p != attributes.end(); ++p)
{
......@@ -1208,7 +1225,7 @@ int authldap_lookup::operator()(int (*callback)(struct authinfo *, void *),
authldap_get_values get_value(main_connection.connection, entry, dn.c_str());
for (std::map<std::string, std::vector<std::string *>>::iterator
for (std::map<std::string, std::vector<std::string *> >::iterator
p=attributes.begin(); p != attributes.end(); ++p)
{
get_value(p->first, p->second);
......
dnl Process this file with autoconf to produce a configure script.
dnl
dnl
dnl Copyright 1998 - 2018 Double Precision, Inc. See COPYING for
dnl Copyright 1998 - 2019 Double Precision, Inc. See COPYING for
dnl distribution information.
AC_PREREQ(2.63)
AC_INIT([courier-authlib],[0.69.0.20181018],[courier-users@lists.sourceforge.net])
AC_INIT([courier-authlib],[0.69.1],[courier-users@lists.sourceforge.net])
AC_CONFIG_SRCDIR([courierauth.h])
......