Module: check_mk
Branch: master
Commit: ff950dfa4b94f96809ee38fa01d1ff1d05eca257
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ff950dfa4b94f9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Nov 16 15:58:56 2012 +0100
ldap: Only use existing connections when connection settings havent changed
---
web/plugins/userdb/ldap.py | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 7379205..18a6aec 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -94,9 +94,10 @@ def ldap_uri():
return uri + '%s:%d' % (config.ldap_connection['server'],
config.ldap_connection['port'])
def ldap_connect():
- global ldap_connection
- if ldap_connection:
- return # Only initialize once.
+ global ldap_connection, ldap_connection_options
+
+ if ldap_connection and config.ldap_connection == ldap_connection_options:
+ return # Use existing connections (if connection settings have not changed)
try:
ldap
@@ -123,6 +124,9 @@ def ldap_connect():
ldap_connection.protocol_version = config.ldap_connection['version']
ldap_default_bind()
+ # on success, store the connection options the connection has been made with
+ ldap_connection_options = config.ldap_connection
+
except ldap.SERVER_DOWN:
ldap_connection = None # Invalidate connection on failure
raise MKLDAPException(_('The LDAP connector is unable to connect to the LDAP
server.'))