Skip Navigation Links | |
Exit Print View | |
Oracle Directory Server Enterprise Edition Developer's Guide 11 g Release 1 (11.1.1.5.0) |
Part I Directory Server Plug-In API Guide
1. Before You Start Writing Plug-Ins
2. Changes to the Plug-In API Since Directory Server 5.2
3. Getting Started With Directory Server Plug-Ins
4. Working With Entries Using Plug-Ins
5. Extending Client Request Handling Using Plug-Ins
Preoperation and Postoperation Plug-Ins
Logging the Authentication Method
To Generate a Bind Log Message
Bypassing Bind Processing in Directory Server
Normal Directory Server Bind Behavior
Extending the Search Operation
Normal Directory Server Search Behavior
Extending the Compare Operation
Prepending a String to an Attribute
Extending the Modify Operation
Extending the Rename Operation
Extending the Delete Operation
6. Handling Authentication Using Plug-Ins
7. Performing Internal Operations With Plug-Ins
8. Writing Entry Store and Entry Fetch Plug-Ins
9. Writing Extended Operation Plug-Ins
10. Writing Matching Rule Plug-Ins
11. Writing Password Storage Scheme Plug-Ins
12. Writing Password Quality Check Plug-Ins
13. Writing Computed Attribute Plug-Ins
Part II Directory Server Plug-In API Reference
14. Data Type and Structure Reference
15. Function Reference, Part I
16. Function Reference, Part II
This section demonstrates functionality called by Directory Server before sending a result code, a referral, or an entry to the client application. Refer to install-path/examples/testpreop.c for the source code discussed here.
The following example shows the code that logs the operation number and user DN.
Example 5-24 Logging and Responding to the Client (testpreop.c)
#include "slapi-plugin.h" int testpreop_send(Slapi_PBlock * pb) { Slapi_Operation * op; /* Operation in progress */ char * connDn; /* Get DN from connection */ int connId, opId, rc = 0; long msgId; rc |= slapi_pblock_get(pb, SLAPI_OPERATION, &op); rc |= slapi_pblock_get(pb, SLAPI_CONN_DN, &connDn); rc |= slapi_pblock_get(pb, SLAPI_CONN_ID, &connId); rc |= slapi_pblock_get(pb, SLAPI_OPERATION_MSGID, &msgId); rc |= slapi_pblock_get(pb, SLAPI_OPERATION_ID, &opId); if (rc == 0) { slapi_log_info_ex( SLAPI_LOG_INFO_AREA_PLUGIN, SLAPI_LOG_INFO_LEVEL_DEFAULT, msgId, connId, opId, "testpreop_send in test-preop plug-in", "Operation: %d\tUser: %s\n", slapi_op_get_type(op), connDn ); } slapi_ch_free_string(&connDn); return (rc); }
Operation identifiers are defined in the plug-in header file install-path/include/slapi-plugin.h. Search for SLAPI_OPERATION_*.
Before using the plug-in function as described here, set up the example suffix and register the plug-in. See Extending the Bind Operation and “To register the Plug-in”, as described previously.
With the plug-in activated in Directory Server, perform a search as Kirsten Vaughan:
$ ldapsearch -h localhost -p 1389 -b dc=example,dc=com \ -D uid=kvaughan,ou=people,dc=example,dc=com -w bribery \ uid=bcubbins
Search instance-path/logs/errors for the log messages. Minus housekeeping information, the first message reflects the bind result:
Operation: 1 User: uid=kvaughan,ou=people,dc=example,dc=com
The next message reflects the search:
Operation: 4 User: uid=kvaughan,ou=people,dc=example,dc=com
Inside plug-in functions, use slapi_op_get_type() to determine the type of an operation. Refer to Part II, Directory Server Plug-In API Reference for info about slapi_op_get_type(), or see the plug-in header file install-path/include/slapi-plugin.h for a list of operation types.