ldap2: remove URI argument from ldap2 constructor

LDAPClient should be used for ad-hoc connections, so the argument is not
necessary, and currently also unused.

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
Jan Cholasta 2017-02-23 10:15:52 +00:00 committed by Martin Basti
parent 8f849a77f5
commit 4736fef6bb
2 changed files with 16 additions and 14 deletions

View File

@ -704,7 +704,16 @@ class LDAPClient(object):
If true, attributes are decoded to Python types according to their
syntax.
"""
self.ldap_uri = ldap_uri
if ldap_uri is not None:
self.ldap_uri = ldap_uri
self.host = 'localhost'
self.port = None
url_data = urlparse(ldap_uri)
self._protocol = url_data.scheme
if self._protocol in ('ldap', 'ldaps'):
self.host = url_data.hostname
self.port = url_data.port
self._start_tls = start_tls
self._force_schema_updates = force_schema_updates
self._no_schema = no_schema
@ -712,14 +721,6 @@ class LDAPClient(object):
self._cacert = cacert
self._sasl_nocanon = sasl_nocanon
self.host = 'localhost'
self.port = None
url_data = urlparse(ldap_uri)
self._protocol = url_data.scheme
if self._protocol in ('ldap', 'ldaps'):
self.host = url_data.hostname
self.port = url_data.port
self.log = log_mgr.get_logger(self)
self._has_schema = False
self._schema = None

View File

@ -67,19 +67,20 @@ class ldap2(CrudBackend, LDAPClient):
LDAP Backend Take 2.
"""
def __init__(self, api, ldap_uri=None):
if ldap_uri is None:
ldap_uri = api.env.ldap_uri
def __init__(self, api):
force_schema_updates = api.env.context in ('installer', 'updates')
CrudBackend.__init__(self, api)
LDAPClient.__init__(self, ldap_uri,
LDAPClient.__init__(self, None,
force_schema_updates=force_schema_updates)
self._time_limit = float(LDAPClient.time_limit)
self._size_limit = int(LDAPClient.size_limit)
@property
def ldap_uri(self):
return self.api.env.ldap_uri
@property
def time_limit(self):
if self._time_limit is None: