aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo/plugins/ldapusers.py
diff options
context:
space:
mode:
authorDan Fandrich <danf@mageia.org>2025-02-03 19:30:47 -0800
committerDan Fandrich <danf@mageia.org>2025-02-03 22:25:12 -0800
commitc488d9cdfb0aea78d4a0bde4778fe78eda1c46ea (patch)
tree034840bfc891f6873f4e2a0bcc86650291433f62 /MgaRepo/plugins/ldapusers.py
parent6d2c594260832373595effa4f63552a8068ae92c (diff)
downloadmgarepo-c488d9cdfb0aea78d4a0bde4778fe78eda1c46ea.tar
mgarepo-c488d9cdfb0aea78d4a0bde4778fe78eda1c46ea.tar.gz
mgarepo-c488d9cdfb0aea78d4a0bde4778fe78eda1c46ea.tar.bz2
mgarepo-c488d9cdfb0aea78d4a0bde4778fe78eda1c46ea.tar.xz
mgarepo-c488d9cdfb0aea78d4a0bde4778fe78eda1c46ea.zip
Fix many errors found by pytypeHEADmaster
Some of these would always cause run-time exceptions, which makes me believe that because these haven't been reported before there's a lot of dead code in here. There are a few more pytype errors that don't have obvious fixes.
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]