From: <mi...@st...> - 2003-12-05 12:13:32
|
Lukas Meyer wrote: > > I want to show the whole tree with a for loop or anything else. Really the whole tree at once? Then you could retrieve the whole sub-tree in one search request and sort the reversed normalized DN into a list or to construct a dictionary-based tree-structure depending on your needs. I'm doing this to reconstruct the correct tree order of entries in LDIF files. Off course this does not scale well on directories with 100000+ entries since it consumes memory. Also be prepared to hit a search limit which will leave your tree incomplete. > hasLeaveEntry() is a funktion that returns 0 or 1 if a subentry is there. > > for name, attrs in l.search_s(dn, ldap.SCOPE_ONELEVEL, > "objectclass=*", []): > x = hasLeaveEntry(name) > if x == 1: > for name, attrs in l.search_s(dn, ldap.SCOPE_ONELEVEL, > "objectclass=*", []): > x = hasLeaveEntry(name) > and so on... > else: > continue It's recursive which might be a problem on highly nested directory trees. Also I'd use the operational attribute 'hasSubordinates' if present or similar to spare the one search request per leaf entry. You might wanna check the sources of web2ldap which do the recursive deletes (file pylib/w2lapp/delete.py). Ciao, Michael. |