how to know the end?

Lukas Meyer lukas at
Fri Nov 28 09:22:51 CET 2003

Hi there,

I want to show the whole ldap structure in a tree. I want to do that 
with a loop that continous searching in each branch it found. But my 
problem is, how I can let the loop know if it is the end btw the last 
branch of a branch. Is there anything to check for that? My current code 
checks everytime the first branch, then the first branch of the first 
branch etc. but if it is at the latest one, it hangs. So I need anything 
how i can say "if you are in the latest one, break the loop".

Below is a code snip of this loop:

basedn = dn
for name, attrs in l.search_s(dn, ldap.SCOPE_ONELEVEL, "objectclass=*", []):
    print name
    newdn = name
    while 1:
        for name, attrs in l.search_s(newdn, ldap.SCOPE_ONELEVEL, 
            newdn = name
            print newdn

Does anyone know a solution to this problem?

Best regards


More information about the python-ldap mailing list