i don't think there is any option like that.
you will have to iterate and delete entries. One gotcha that i would like to mention is you can't delete an OU with objects under it, unless you have a different setting in AD.
Domanda
Using python-ldap, I want to delete an entire subtree of my LDAP tree.
I came up with :
def ldap_recursive_delete_s(con, base_dn):
search = con.search_s(base_dn, ldap.SCOPE_SUBTREE)
delete_list = [dn for dn, _ in search]
delete_list.reverse()
for dn in delete_list:
con.delete_s(dn)
I was wondering if there is any kind of "recursive" option like with the ldaprm
CLI tool.
Soluzione 2
i don't think there is any option like that.
you will have to iterate and delete entries. One gotcha that i would like to mention is you can't delete an OU with objects under it, unless you have a different setting in AD.
Altri suggerimenti
For those who might stumble on this question later, here's a quick and dirty piece I wrote for myself (Essentially what @navendu says):
def recursive_delete(conn, base_dn):
search = conn.search_s(base_dn, ldap.SCOPE_ONELEVEL)
for dn, _ in search:
recursive_delete(conn, dn)
print "Deleting: ", base_dn
conn.delete_s(base_dn)