Compare commits

..

No commits in common. "cbb97ae726bb0d5f3381a765b16754595251685b" and "e8de509346ccd05b1d820be77671ca0d1d103962" have entirely different histories.

View file

@ -30,13 +30,11 @@ class LdapServer:
con = 0
def __init__(self, uri, dn=None, pwd=None, v2=None,
raiseOnError=False, logger=False, checkCert=True):
def __init__(self, uri, dn=None, pwd=None, v2=None, raiseOnError=False, logger=False):
self.uri = uri
self.dn = dn
self.pwd = pwd
self.raiseOnError = raiseOnError
self.checkCert = checkCert
if v2:
self.v2 = True
if logger:
@ -53,8 +51,6 @@ class LdapServer:
""" Start connection to LDAP server """
if self.con == 0:
try:
if not self.checkCert:
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, ldap.OPT_X_TLS_NEVER)
con = ldap.initialize(self.uri)
if self.v2:
con.protocol_version = ldap.VERSION2 # pylint: disable=no-member
@ -389,8 +385,7 @@ class LdapClient:
# Load configuration option types only here to avoid global
# dependency of ldap module with config one.
# pylint: disable=import-outside-toplevel
from mylib.config import BooleanOption, StringOption, PasswordOption
from mylib.config import StringOption, PasswordOption # pylint: disable=import-outside-toplevel
section = self._config.add_section(
self._config_section,
@ -406,9 +401,6 @@ class LdapClient:
PasswordOption, 'bindpwd',
comment='LDAP Bind password (set to "keyring" to use XDG keyring)',
username_option='binddn', keyring_value='keyring')
section.add_option(
BooleanOption, 'checkcert', default=True,
comment='Check LDAP certificate')
return section
@ -421,7 +413,7 @@ class LdapClient:
log.info("Connect to LDAP server %s as %s", uri, binddn if binddn else 'annonymous')
self._conn = LdapServer(
uri, dn=binddn, pwd=self._get_option('bindpwd'),
checkCert=self._get_option('checkcert'), raiseOnError=True
raiseOnError=True
)
# Reset cache
self._cached_objects = {}
@ -697,8 +689,6 @@ class LdapClient:
:param changes: The changes as returned by get_changes
"""
if changes is None:
return False
assert self._conn or self.initialize()
return self._conn.update_need(
changes[0], changes[1],