title: Delete recursively a LDAP subtree with python
body: <p>Using <a href="http://www.python-ldap.org/" rel="nofollow">python-ldap</a>, I want to delete an entire subtree of my LDAP tree.</p>
  
  <p>I came up with :</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>I was wondering if there is any kind of "recursive" option like with the <code>ldaprm</code> CLI tool.</p>