This section demonstrates functionality called by Directory Server after a client modify RDN 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.
#include "slapi-plugin.h" int testpostop_modrdn( Slapi_PBlock *pb ) { char * dn; /* DN of entry to rename */ char * newrdn; /* New RDN */ int dflag; /* Delete the old RDN? */ int is_repl = 0; /* Is this replication? */ int connId, opId, rc = 0; long msgId; rc |= slapi_pblock_get(pb, SLAPI_MODRDN_TARGET, &dn); rc |= slapi_pblock_get(pb, SLAPI_MODRDN_NEWRDN, &newrdn); rc |= slapi_pblock_get(pb, SLAPI_MODRDN_DELOLDRDN, &dflag); 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); slapi_log_info_ex( SLAPI_LOG_INFO_AREA_PLUGIN, SLAPI_LOG_INFO_LEVEL_DEFAULT, msgId, connId, opId, "testpostop_modrdn in test-postop plug-in", "Modrdn entry (%s)\n", dn ); /* In general, do not interfere in replication operations. */ /* Log the DN of the renamed entry, its new RDN, and the flag * indicating whether the old RDN was removed to the change log. */ if (!is_repl) write_changelog(_MODRDN, dn, (void *) newrdn, dflag); return (rc); }
Check that Quentin’s entry is in the directory as shown in Extending the Modify Operation.
Last weekend, Quentin decided to change his given name to Fred. His user ID is now fcubbins, so his entry must be renamed. With this plug-in activated in Directory Server, modify the entry.
$ ldapmodify -D uid=kvaughan,ou=people,dc=example,dc=com -w bribery \ -h localhost -p 1389 dn: uid=qcubbins,ou=People,dc=example,dc=com changetype: modify replace: givenName givenName: Fred dn: uid=qcubbins,ou=People,dc=example,dc=com changetype: modify replace: mail mail: fcubbins@example.com dn: uid=qcubbins,ou=People,dc=example,dc=com changetype: modify replace: cn cn: Fred Cubbins dn: uid=qcubbins,ou=People,dc=example,dc=com changetype: modrdn newrdn: uid=fcubbins deleteoldrdn: 1 ^D |
Search instance-path/logs/errors for the log message. If you ignore housekeeping information, you get the following message:
Modrdn entry (uid=qcubbins,ou=people,dc=example,dc=com)
Notice also the information that is logged to changelog.txt.
time: 21120506184432 dn: uid=qcubbins,ou=people,dc=example,dc=com changetype: modrdn newrdn: uid=fcubbins deleteoldrdn: 1 |