Skip to content

Conversation

duffyjp
Copy link
Contributor

@duffyjp duffyjp commented Apr 4, 2016

delete_tree checks if you LDAP server supports the DELETE_TREE control code and then either uses it, or recursively deletes instead-- to the same effect.

@duffyjp
Copy link
Contributor Author

duffyjp commented Apr 6, 2016

I tracked down the source code for "ldapdelete" and it looks like that always does a recursive delete, rather than using the control code. I see no reason not to use DELETE_TREE if it's available though.

https://opensource.apple.com/source/OpenLDAP/OpenLDAP-208.5/OpenLDAP/clients/tools/ldapdelete.c

Here's an interesting chunk. If you pass -r it does a recursive delete, if not it just tries to delete the entity and fails if it has children. Like ruby-net-ldap's delete.

    /* If prune is on, remove a whole subtree.  Delete the children of the
     * DN recursively, then the DN requested.
     */
    if ( prune ) {
retry:;
        deletechildren( ld, dn, subentries );
    }

    rc = ldap_delete_ext( ld, dn, NULL, NULL, &id );

Copy link
Member

@HarlemSquirrel HarlemSquirrel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! Would you be able to write a test for this?

Copy link
Member

@HarlemSquirrel HarlemSquirrel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got a test for this ready. It looks like OpenLDAP doesn't support the delete tree control and we didn't have a test for this.

@HarlemSquirrel HarlemSquirrel merged commit 387d6e6 into ruby-ldap:master Aug 18, 2020
@HarlemSquirrel HarlemSquirrel added this to the v0.17 milestone Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants