diff options
| author | 2019-11-13 15:24:45 +0000 | |
|---|---|---|
| committer | 2019-11-13 15:24:45 +0000 | |
| commit | 7b689363218f1f7cd8d07c4ec3eaf03788b196c1 (patch) | |
| tree | 37bb397e948eac74cbd96a7e6ab637837622ffa0 /src/modules/extra/m_ldap.cpp | |
| parent | Merge branch 'insp3' into master. (diff) | |
| parent | Improve the logic around connecting to a MySQL server. (diff) | |
Merge branch 'insp3' into master.
Diffstat (limited to 'src/modules/extra/m_ldap.cpp')
| -rw-r--r-- | src/modules/extra/m_ldap.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index 8af5f2aec..52adb383e 100644 --- a/src/modules/extra/m_ldap.cpp +++ b/src/modules/extra/m_ldap.cpp @@ -247,6 +247,17 @@ class LDAPService : public LDAPProvider, public SocketThread Connect(); } + int SetOption(int option, const void* value) + { + int ret = ldap_set_option(this->con, option, value); + if (ret != LDAP_OPT_SUCCESS) + { + ldap_unbind_ext(this->con, NULL, NULL); + this->con = NULL; + } + return ret; + } + void QueueRequest(LDAPRequest* r) { this->LockQueue(); @@ -318,22 +329,14 @@ class LDAPService : public LDAPProvider, public SocketThread 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); + i = SetOption(LDAP_OPT_PROTOCOL_VERSION, &version); if (i != LDAP_OPT_SUCCESS) - { - ldap_unbind_ext(this->con, NULL, NULL); - this->con = NULL; 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); + i = SetOption(LDAP_OPT_NETWORK_TIMEOUT, &tv); if (i != LDAP_OPT_SUCCESS) - { - ldap_unbind_ext(this->con, NULL, NULL); - this->con = NULL; throw LDAPException("Unable to set timeout for " + this->name + ": " + ldap_err2string(i)); - } } void BindAsManager(LDAPInterface* i) override |
