[python-ldap] AttributeError: ReconnectLDAPObject has no attribute '_l'

Florian Best best at univention.de
Thu Jan 5 13:07:23 EST 2017


Hello :)

As there doesn't seem to be a bug reporting system, I will post to this
mailing list.

I got the following traceback:

    res = self.lo.search_ext_s(base, ldap_scope, filter, attr, serverctrls=serverctrls, clientctrls=None, timeout=timeout, sizelimit=sizelimit)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 918, in search_ext_s
    return self._apply_method_s(SimpleLDAPObject.search_ext_s,*args,**kwargs)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 865, in _apply_method_s
    self.reconnect(self._uri,retry_max=self._retry_max,retry_delay=self._retry_delay)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 843, in reconnect
    SimpleLDAPObject.unbind_s(self)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 600, in unbind_s
    return self.unbind_ext_s(None,None)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 591, in unbind_ext_s
    msgid = self.unbind_ext(serverctrls,clientctrls)
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 588, in unbind_ext
    return self._ldap_call(self._l.unbind_ext,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls))
  File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 136, in __getattr__
    self.__class__.__name__,repr(name)
AttributeError: ReconnectLDAPObject has no attribute '_l'

I have two assumtions about this, but I am not completely sure as this
is only a traceback reported by one of our customers and I couldn't
properly reproduce it. Maybe you have another explanation.

The first, more probable reason is because unbind_s() is called twice:
During the reconnection SimpleLDAPObject.unbind_s() is called first in
_apply_method_s() and second in reconnect() while the server is still
down. The second call would cause that SimpleLDAPObject.unbind_s() calls
a method which uses self._l while reconnect() already removed self._l.

(The second thing I could imagine would be If two threads use the same
object, this can happen during the reconnection?)

I attached a patch which maybe prevent this, as _l is not removed
anymore from the namespace of that object.
The expected behavior would be that just ldap.SERVER_DOWN would be
raised (and not AttributeError which can't be really handled without
parsing the exception message and wrapping every ldap call).

Best regards
Florian

-- 
Florian Best
Open Source Software Engineer
 
Univention GmbH
be open
Mary-Somerville-Str.1
28359 Bremen
Tel.: +49 421 22232-0
Fax : +49 421 22232-99

best at univention.de
http://www.univention.de

Geschäftsführer: Peter H. Ganten
HRB 20755 Amtsgericht Bremen
Steuer-Nr.: 71-597-02876

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20170105/d65e85d8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: attribute_error.patch
Type: text/x-diff
Size: 1751 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20170105/d65e85d8/attachment.patch>


More information about the python-ldap mailing list