aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo/plugins/ldapusers.py
diff options
context:
space:
mode:
Diffstat (limited to 'MgaRepo/plugins/ldapusers.py')
-rw-r--r--MgaRepo/plugins/ldapusers.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/MgaRepo/plugins/ldapusers.py b/MgaRepo/plugins/ldapusers.py
index 0edc417..5822cf3 100644
--- a/MgaRepo/plugins/ldapusers.py
+++ b/MgaRepo/plugins/ldapusers.py
@@ -137,13 +137,12 @@ def make_handler():
"'yes' or 'no'" % raw)
try:
- from ldap3 import Server, Connection, ALL
+ import ldap3
#import ldap
except ImportError:
raise Error("LDAP support needs the ldap3 package "\
"to be installed")
- else:
- from ldap.utils.conv import escape_filter_chars
+ from ldap3.utils.conv import escape_filter_chars
def users_wrapper(section, option=None, default=None, walk=False):
global users_cache
@@ -158,23 +157,23 @@ def make_handler():
try:
#l = ldap.initialize(uri)
- l = Connection(uri, auto_bind=True, use_tls=starttls)
+ l = ldap3.Connection(uri, auto_bind=True, use_tls=starttls)
# if starttls:
# l.start_tls() #l.start_tls_s()
if binddn:
l.bind(binddn, bindpw)
- except ldap3.LDAPExceptionError as e:
+ except ldap3.core.exceptions.LDAPExceptionError as e:
raise LDAPError(e)
try:
data = {"username": escape_filter_chars(option)}
filter = interpolate("ldap-filterformat", filterformat, data)
attrs = used_attributes(format)
try:
- found = l.search(search_base='o='.basedn, search_filter=filter,
- attributes=attrs, search_scope=SUBTREE)
+ found = l.search(search_base='o='+basedn, search_filter=filter,
+ attributes=attrs, search_scope=ldap3.SUBTREE)
# found = l.search_s(basedn, ldap.SCOPE_SUBTREE, filter,
# attrlist=attrs)
- except ldap3.LDAPError as e:
+ except ldap3.core.exceptions.LDAPException as e:
raise LDAPError(e)
if found:
dn, entry = found[0]