python-ldap on woody
Anyone successfully using python-ldap on woody? I can't get the
example to work - it infinite loops for me.
Here's the example code (comments removed - and some small changes
made to match the fields on the ldap server - the original example is
at http://homepage.mac.com/mengelhart/python-ldap-samples.html#search):
import ldap
try:
l = ldap.open("127.0.0.1")
l.protocol_version = ldap.VERSION3
except ldap.LDAPError, e:
print e
# Changed from example - set a base dn that exists
baseDN = "ou=mailingList,dc=longship,dc=org"
# Changed from example - require one and not sub (sub shows same symptom)
searchScope = ldap.SCOPE_ONELEVEL
retrieveAttributes = None
searchFilter = "(objectclass=*)"
try:
ldap_result_id = l.search(baseDN, searchScope, searchFilter, retrieveAttributes)
result_set = []
while 1:
result_type, result_data = l.result(ldap_result_id, 0)
if (result_data == []):
break
else:
# Next two lines added to show what happening
print "T", result_type
print "D", result_type
if result_type == ldap.RES_SEARCH_ENTRY:
result_set.append(result_data)
print result_set
except ldap.LDAPError, e:
print e
This returns
T None
D None
T None
D None
T None
D None
<many repeated lines>
T RES_SEARCH_ENTRY
D RES_SEARCH_ENTRY
T RES_SEARCH_ENTRY
D RES_SEARCH_ENTRY
T RES_SEARCH_ENTRY
D RES_SEARCH_ENTRY
T RES_SEARCH_ENTRY
D RES_SEARCH_ENTRY
T RES_SEARCH_ENTRY
D RES_SEARCH_ENTRY
T RES_SEARCH_RESULT
D RES_SEARCH_RESULT
T None
D None
T None
D None
T None
D None
<many repeated lines>
and doesn't return. T None, D None just continue until I interrupt the
process.
php-ldap, perl (Net::LDAP) and ldapsearch all correctly return 5
objects.
I'm no python programmer, but I need to synchronize some mailman lists
with ldap data - so if anyone can give me any suggestions - I'd be
grateful :-)
--
Chris Searle
debian@chrissearle.org
Reply to: