15.14. Deleting an Object
You want to delete an object or container from Active Directory.
Using a graphical user interface
Open ADSI Edit.
If an entry for the naming context you want to browse is not already displayed, do the following:
Right-click on ADSI Edit in the right pane and click Connect to....
Fill in the information for the naming context, container, or OU where the object you want to delete is contained. Click on the Advanced button if you need to enter alternate credentials.
In the left pane, browse to the object you want to delete.
Right-click on the object and select Delete.
Click Yes to confirm.
Using a command-line interface
Use the following command to delete a single object:
> dsrm "
Use the following command to delete a container and its child objects:
> dsrm "
strObjectDN = "
<ObjectDN>" set objUser = GetObject("LDAP://" & strObjectDN) objUser.DeleteObject(0)
There is not much difference between deleting a leaf node and deleting a container that has child objects. However, there is a distinction in what is happening in the background.
Deleting an object that has no children can be done with a simple LDAP delete operation. On the other hand, to delete a container and its children, the tree delete LDAP control has to be used. If you were to do the deletion from an LDAP-based tool like LDP, you would first need to enable the Subtree Delete control, which has an OID of 1.2.840.1135188.8.131.525. LDP provides ...