[python-ldap] Assertion Failed Error

Cantu, Liza J lcantu at austin.utexas.edu
Fri Sep 12 18:59:17 CEST 2014


Hello,

I have a very tricky issue to debug. I am working on a project on my local server and I am receiving the following error when making a call using ldap:
python: references.c:33: ldap_first_reference: Assertion `( (ld)->ld_options.ldo_valid == 0x2 )' failed. Aborted

My project uses Python 2.6, Django 1.4.14, and python ldap 2.3.12. The bind appears to be successful but then the connection is "closed (connection lost)". I have verified that my credentials are correct. The issue mostly happens when working locally on our VM, but it also has affected our code in production. To my knowledge, there is no way in Python to catch this error - it completely breaks our code and causes a server error.

I've been using pdb to step through the relevant code, which is essentially:

try:
    l = ldap.initialize("ldaps://" + host)
    l.simple_bind_s(user_name, user_pass)
    results = l.search_s(base_dn, ldap.SCOPE_SUBTREE, query, srch_attrs)

The calls to initialize and simple_bind_s both complete successfully; it is when we start drilling into search_s that we eventually hit the error in the _ldap_call method of the SimpleLDAPObject class:

def _ldap_call(self,func,*args,**kwargs):
  """
  Wrapper method mainly for serializing calls into OpenLDAP libs
  and trace logs
  """
  self._ldap_object_lock.acquire()
  if __debug__:
    if self._trace_level>=1:# and func.__name__!='result':
      self._trace_file.write('*** %s - %s (%s,%s)\n' % (
       self._uri,
        self.__class__.__name__+'.'+func.__name__,
        repr(args),repr(kwargs)
      ))
      if self._trace_level>=3:
        traceback.print_stack(limit=self._trace_stack_limit,file=self._trace_file)
  try:
    try:
      result = func(*args,**kwargs)

It bombs as soon as it tries assigning a value to result; the relevant arguments at that point are:

self = <ldap.ldapobject.SimpleLDAPObject instance at 0xb5e4fcac>
func = <built-in method result3 of LDAP object at 0xb65c2e30>
args = (1, 1, -1)
kwargs = {}

Has anyone seen this issue? Or can anyone shed some light on what I am doing wrong?

Thanks,
Liza
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20140912/7b6616b0/attachment.html>


More information about the python-ldap mailing list