Sun Java System Directory Server Enterprise Edition 6.3 Developer's Guide

Extending the Delete Operation

This section shows how to develop functionality called by Directory Server after a client delete operation. A preoperation plug-in, not demonstrated here, can be found in install-path/examples/testpreop.c. Refer to install-path/examples/testpostop.c for the source code discussed here.

Before using the plug-in function as described here, set up Directory Server as described in Logging the Entry to Add, making sure to add Quentin’s entry.

The testpostop_modrdn() function logs the DN of the modified entry and also writes the entry to a log managed by the plug-in, changelog.txt. The location of changelog.txt depends on the platform, as shown in the source code.

The following example shows the code that performs the logging.

Example 6–22 Tracking Entry Deletion (testpostop.c)

#include "slapi-plugin.h"

testpostop_del( Slapi_PBlock *pb )
    char * dn;                         /* DN of entry to delete      */
    int    is_repl = 0;                /* Is this replication?       */
    int    connId, opId, rc = 0;
    long   msgId;

    rc |= slapi_pblock_get(pb, SLAPI_DELETE_TARGET,           &dn);
    rc |= slapi_pblock_get(pb, SLAPI_OPERATION_MSGID,         &msgId);
    rc |= slapi_pblock_get(pb, SLAPI_CONN_ID,                 &connId);
    rc |= slapi_pblock_get(pb, SLAPI_OPERATION_ID,            &opId);
    rc |= slapi_pblock_get(pb, SLAPI_IS_REPLICATED_OPERATION, &is_repl);
    if (rc != 0) return (rc);
        "testpostop_del in test-postop plug-in",
        "Deleted entry (%s)\n", dn

    /* In general, do not interfere in replication operations.       */
    /* Log the DN of the deleted entry to the change log.            */
    if (!is_repl) write_changelog(_DEL, dn, NULL, 0);

    return (rc);

First, check that Quentin’s entry is in the directory as shown in Extending the Modify Operation.

Quentin’s name might be Fred if you have renamed the entry as described in Extending the Rename Operation.

Imagine that Quentin shouted copious verbal abuse at a key customer causing Quentin to be fired from With this plug-in activated in Directory Server, delete his entry.

$ ldapdelete -D uid=kvaughan,ou=people,dc=example,dc=com -w bribery \

Search instance-path/logs/errors for the log message. If you ignore housekeeping information, you get the following message:

Deleted entry (uid=qcubbins,ou=people,dc=example,dc=com)

Notice also the information logged to changelog.txt as shown in the following example.

Example 6–23 Example changelog.txt After Deletion

time: 21120506185404
dn: uid=qcubbins,ou=people,dc=example,dc=com
changetype: delete