summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2016-08-17 17:24:17 +0200
committerAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2016-08-17 21:00:05 +0200
commit11fcd6be74b5782b5bc206becc3cce6d0b7c17ff (patch)
treeb58089d573de31a7fe6f889b659832ccf7332522 /src/lib/Bcfg2/Server/Plugins
parent8bcd3b7d717186f14bdd2482e46c2a6feee51767 (diff)
downloadbcfg2-11fcd6be74b5782b5bc206becc3cce6d0b7c17ff.tar.gz
bcfg2-11fcd6be74b5782b5bc206becc3cce6d0b7c17ff.tar.bz2
bcfg2-11fcd6be74b5782b5bc206becc3cce6d0b7c17ff.zip
Server/Plugins/Ldap: Module should be importable without the python-ldap
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Ldap.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Ldap.py b/src/lib/Bcfg2/Server/Plugins/Ldap.py
index 895c6380f..757150300 100644
--- a/src/lib/Bcfg2/Server/Plugins/Ldap.py
+++ b/src/lib/Bcfg2/Server/Plugins/Ldap.py
@@ -119,22 +119,27 @@ class Ldap(Bcfg2.Server.Plugin.Plugin,
class LdapConnection(Debuggable):
""" Connection to an LDAP server. """
- __scopes__ = {
- 'base': ldap.SCOPE_BASE,
- 'one': ldap.SCOPE_ONELEVEL,
- 'sub': ldap.SCOPE_SUBTREE,
- }
-
def __init__(self, host="localhost", port=389, binddn=None,
bindpw=None):
Debuggable.__init__(self)
+ if HAS_LDAP:
+ msg = "Python ldap module is required for Ldap plugin"
+ self.logger.error(msg)
+ raise Bcfg2.Server.Plugin.PluginInitError(msg)
+
self.host = host
self.port = port
self.binddn = binddn
self.bindpw = bindpw
self.conn = None
+ self.__scopes__ = {
+ 'base': ldap.SCOPE_BASE,
+ 'one': ldap.SCOPE_ONELEVEL,
+ 'sub': ldap.SCOPE_SUBTREE,
+ }
+
def __del__(self):
""" Disconnection if the instance is destroyed. """
self.disconnect()