diff options
author | Adam <Adam@anope.org> | 2015-07-23 08:23:48 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2015-07-23 08:23:48 -0400 |
commit | 63dbd7fbf07309b40e1ef2d911e922bc3b75a139 (patch) | |
tree | c033a2da86b5c9e32f001dcc21d1c065dc1ebeba /modules/extra/m_ldap.cpp | |
parent | 7fe0543bc67b772c6d3ac9a8d9aa6ae2725ed72e (diff) |
Set LDAP_OPT_PROTOCOL_VERSION 3 etc on reconnect, too
Diffstat (limited to 'modules/extra/m_ldap.cpp')
-rw-r--r-- | modules/extra/m_ldap.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/modules/extra/m_ldap.cpp b/modules/extra/m_ldap.cpp index ff63be5c6..26ee7f4a8 100644 --- a/modules/extra/m_ldap.cpp +++ b/modules/extra/m_ldap.cpp @@ -187,6 +187,23 @@ class LDAPService : public LDAPProvider, public Thread, public Condition } private: + void Connect() + { + int i = ldap_initialize(&this->con, this->server.c_str()); + if (i != LDAP_SUCCESS) + throw LDAPException("Unable to connect to LDAP service " + this->name + ": " + ldap_err2string(i)); + + const int version = LDAP_VERSION3; + i = ldap_set_option(this->con, LDAP_OPT_PROTOCOL_VERSION, &version); + if (i != LDAP_OPT_SUCCESS) + throw LDAPException("Unable to set protocol version for " + this->name + ": " + ldap_err2string(i)); + + const struct timeval tv = { 0, 0 }; + i = ldap_set_option(this->con, LDAP_OPT_NETWORK_TIMEOUT, &tv); + if (i != LDAP_OPT_SUCCESS) + throw LDAPException("Unable to set timeout for " + this->name + ": " + ldap_err2string(i)); + } + void Reconnect() { /* Only try one connect a minute. It is an expensive blocking operation */ @@ -195,9 +212,8 @@ class LDAPService : public LDAPProvider, public Thread, public Condition last_connect = Anope::CurTime; ldap_unbind_ext(this->con, NULL, NULL); - int i = ldap_initialize(&this->con, this->server.c_str()); - if (i != LDAP_SUCCESS) - throw LDAPException("Unable to connect to LDAP service " + this->name + ": " + ldap_err2string(i)); + + Connect(); } void QueueRequest(LDAPRequest *r) @@ -215,19 +231,7 @@ class LDAPService : public LDAPProvider, public Thread, public Condition LDAPService(Module *o, const Anope::string &n, const Anope::string &s, int po, const Anope::string &b, const Anope::string &p, time_t t) : LDAPProvider(o, n), server(s), port(po), admin_binddn(b), admin_pass(p), timeout(t), last_connect(0) { - int i = ldap_initialize(&this->con, this->server.c_str()); - if (i != LDAP_SUCCESS) - throw LDAPException("Unable to connect to LDAP service " + this->name + ": " + ldap_err2string(i)); - - const int version = LDAP_VERSION3; - i = ldap_set_option(this->con, LDAP_OPT_PROTOCOL_VERSION, &version); - if (i != LDAP_OPT_SUCCESS) - throw LDAPException("Unable to set protocol version for " + this->name + ": " + ldap_err2string(i)); - - const struct timeval tv = { 0, 0 }; - i = ldap_set_option(this->con, LDAP_OPT_NETWORK_TIMEOUT, &tv); - if (i != LDAP_OPT_SUCCESS) - throw LDAPException("Unable to set timeout for " + this->name + ": " + ldap_err2string(i)); + Connect(); } ~LDAPService() |