[python-ldap] LDAPError has wrong type, gives AttributeError

Viktor ubuntu at fachschaft.physik.uni-bielefeld.de
Fri Jun 29 17:07:47 CEST 2012


Hi,
I am trying to write a cronjob that asks an LDAP-server periodically to
get the members for mailing lists that are then fed to mailman. It
already is working, but I am now trying to modularize it more in order
to make the version public. When the connection is established, I have
the following lines:

try:
	conn = ldap.initialize(uri)
	conn.simple_bind_s('','')
	lists = conn.search_s(oulists + "," + base, ldap.SCOPE_SUBTREE, ,
(objectClass=groupOfNames)", [])
	people = conn.search_s(oupeople + "," + base, ldap.SCOPE_SUBTREE,
"(objectClass=*)", [])
	conn.unbind_s()
except ldap.LDAPError as errors:
	print(errors)
	for error in errors.args:
		if error.has_key('desc'):
			syslog.syslog(syslog.LOG_ERR, error['desc'])
		if error.has_key('info'):
			syslog.syslog(syslog.LOG_ERR, error['info'])
	return False

This usually worked and I did not change this part, but now I get an error:

AttributeError: 'int' object has no attribute 'has_key'

If I add a "print(errors)" to the except clause, I get

(11, 'Resource temporarily unavailable')

which explains the error but is not in accordance with the documentation
( http://www.python-ldap.org/doc/html/ldap.html#exceptions )

Does anyone have an idea what is going wrong?


More information about the python-ldap mailing list