[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: How can I DELETE a complete tree

> sorry,
> The questions was: How can I DELETE a complete tree?

A possible script to do this with OpenLDAP 1.2.x is:

    ldapsearch -b "$base" objectclass=\* dn | grep -v '^$' | ldapdelete -c

where $base is the base of the subtree to be deleted.  Of course, there's
a rather ugly problem with this script which is that it must be run several
times.  This is because the dn's come out in the opposite order you need
in order to delete them.  If you had a program to reverse the order of the
output, then this would work in one pass, ie.:

  ldapsearch -b "$base" objectclass=\* dn | grep -v '^$' | reverse | ldapdelete

OpenLDAP version 2 (just starting in beta) has a -r option in the ldapdelete
command, for recursive deletion.