summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2009-08-01 21:05:06 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2009-08-01 21:05:06 +0000
commit60a68720211304bb62936be68e8ad40f58ca8a85 (patch)
treebf0f4a10e33fd69a5dd8a69e8ca2cc48777dd9e9
parent922cec5bc322c659e5014af82b8083b7ff93d225 (diff)
Reconnect to LDAP server if connection goes away, fixes bug #818.
NOTE: I don't have an LDAP setup, so I'm totally in the blind on these commits. Sorry, but it seems nobody else can be arsed to do it, so I will. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11448 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/extra/m_ldapauth.cpp24
-rw-r--r--src/modules/extra/m_ldapoper.cpp20
2 files changed, 34 insertions, 10 deletions
diff --git a/src/modules/extra/m_ldapauth.cpp b/src/modules/extra/m_ldapauth.cpp
index b95d32b18..1bc0925da 100644
--- a/src/modules/extra/m_ldapauth.cpp
+++ b/src/modules/extra/m_ldapauth.cpp
@@ -142,12 +142,24 @@ public:
if ((res = ldap_sasl_bind_s(conn, username.c_str(), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL)) != LDAP_SUCCESS)
{
- free(authpass);
- if (verbose)
- ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s!%s@%s (LDAP bind failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), ldap_err2string(res));
- ldap_unbind_ext(conn, NULL, NULL);
- conn = NULL;
- return false;
+ if (res == LDAP_SERVER_DOWN)
+ {
+ // Attempt to reconnect if the connection dropped
+ if (verbose)
+ ServerInstance->SNO->WriteToSnomask('a', "LDAP server has gone away - reconnecting...");
+ Connect();
+ res = ldap_sasl_bind_s(conn, username.c_str(), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL);
+ }
+
+ if (res != LDAP_SUCCESS)
+ {
+ if (verbose)
+ ServerInstance->SNO->WriteToSnoMask('c', "Forbidden connection from %s!%s@%s (LDAP bind failed: %s)", user->nick.c_str(), user->ident.c_str(), user->host.c_str(), ldap_err2string(res));
+ free(authpass);
+ ldap_unbind_ext(conn, NULL, NULL);
+ conn = NULL;
+ return false;
+ }
}
free(authpass);
diff --git a/src/modules/extra/m_ldapoper.cpp b/src/modules/extra/m_ldapoper.cpp
index 43525aa4d..c46bdcf0d 100644
--- a/src/modules/extra/m_ldapoper.cpp
+++ b/src/modules/extra/m_ldapoper.cpp
@@ -127,10 +127,22 @@ public:
if ((res = ldap_sasl_bind_s(conn, username.c_str(), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL)) != LDAP_SUCCESS)
{
- free(authpass);
- ldap_unbind_ext(conn, NULL, NULL);
- conn = NULL;
- return false;
+ if (res == LDAP_SERVER_DOWN)
+ {
+ // Attempt to reconnect if the connection dropped
+ if (verbose)
+ ServerInstance->SNO->WriteToSnomask('a', "LDAP server has gone away - reconnecting...");
+ Connect();
+ res = ldap_sasl_bind_s(conn, username.c_str(), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL);
+ }
+
+ if (res != LDAP_SUCCESS)
+ {
+ free(authpass);
+ ldap_unbind_ext(conn, NULL, NULL);
+ conn = NULL;
+ return false;
+ }
}
free(authpass);