1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
# BEGIN COPYRIGHT BLOCK
# This Program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; version 2 of the License.
#
# This Program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA.
#
# In addition, as a special exception, Red Hat, Inc. gives You the additional
# right to link the code of this Program with code not covered under the GNU
# General Public License ("Non-GPL Code") and to distribute linked combinations
# including the two, subject to the limitations in this paragraph. Non-GPL Code
# permitted under this exception must only link to the code of this Program
# through those well defined interfaces identified in the file named EXCEPTION
# found in the source code files (the "Approved Interfaces"). The files of
# Non-GPL Code may instantiate templates or use macros or inline functions from
# the Approved Interfaces without causing the resulting work to be covered by
# the GNU General Public License. Only Red Hat, Inc. may make changes or
# additions to the list of Approved Interfaces. You must obey the GNU General
# Public License in all respects for all of the Program code and other code used
# in conjunction with the Program except the Non-GPL Code covered by this
# exception. If you modify this file, you may extend this exception to your
# version of the file, but you are not obligated to do so. If you do not wish to
# provide this exception without modification, you must delete this exception
# statement from your version and license this file solely under the GPL without
# exception.
#
#
# Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
# Copyright (C) 2005 Red Hat, Inc.
# All rights reserved.
# END COPYRIGHT BLOCK
#
----------------------------
Sample Server Plug-Ins
for Directory Server
----------------------------
This directory contains code for some sample server plug-ins.
NOTE: Before you compile and run these examples, make sure
to change any server-specific data in the examples to
values applicable to your Directory Server.
testbind.c
----------
This is an example of a pre-operation bind plug-in function that
handles authentication. When processing an LDAP bind request, the
server calls this plug-in function before calling the database bind
function.
testentry.c
-----------
This is an example of an entry store plug-in function and an entry fetch
plug-in function. You must be using the default database (not your own
back-end database) in order for these plug-in functions to work.
testextendedop.c
----------------
This is an example of an extended operation plug-in function that
handles requests for the extended operation with the OID 1.2.3.4.
The example should be used in conjunction with the reqextop.c and
ReqExtOp.java clients (the source code for these clients is located
in the clients subdirectory). These clients are capable of requesting
the extended operation with the OID 1.2.3.4.
testpostop.c
------------
This contains examples of post-operation plug-in functions. These
functions are called after the server processes LDAP operations.
The functions log changes to the directory in a change log file.
testpreop.c
-----------
This contains examples of pre-operation plug-in functions. These
functions are called before the server processes LDAP operations.
testsaslbind.c
--------------
This is an example of a pre-operation plug-in function that
implements a SASL mechanism.
sampletask.c
------------
This is an example of task plug-in that implements a task which is
invoked by adding the corresponding task entry.
clients
-------
This directory contains the C and Java source code for clients
that you can use to test the server plug-ins. See the README
file in that directory for details.
----------------------------
How To Create
A Server Plug-In
----------------------------
Text between brackets ([]) should be replaced with values specific to
your situation.
Creating the Plug-In Library
----------------------------
Server plug-ins are built as libraries available to the server.
1. Include the Plug-In API. For example:
#include "slapi-plugin.h"
2. Write your plug-in, including a top level initialization function
used by the server to start the plug-in. For example:
/* Plug-in functions defined here */
int my_plugin_init( Slapi_PBlock *pb ) /* initialize param. block */
{
/* Set or get the parameters in pb */
slapi_pblock_set();
slapi_pblock_get();
/* Plug-in functions registered here */
if (error)
{
slapi_log_error();
return error_code;
}
else return 0;
} /* my_plugin_init() */
See the Parameter Block Reference in the Red Hat Directory Server
Plug-In Programmer's Guide for hints on plug-in types.
3. Build the plug-in as a library.
We recommend to use the Directory Server's build scheme.
3.1 Add your plugin to Makefile.am
Index: Makefile.am
===================================================================
RCS file: /cvs/dirsec/ldapserver/Makefile.am,v
retrieving revision 1.14
diff -t -w -U2 -r1.14 Makefile.am
--- Makefile.am 16 Nov 2006 18:56:03 -0000 1.14
+++ Makefile.am 14 Dec 2006 23:51:30 -0000
@@ -74,5 +74,5 @@
serverplugin_LTLIBRARIES = libacl-plugin.la libattr-unique-plugin.la libchainingdb-plugin.la \
- libcos-plugin.la libdes-plugin.la libdistrib-plugin.la \
+ libsampletask-plugin.la libcos-plugin.la libdes-plugin.la libdistrib-plugin.la \
libhttp-client-plugin.la libcollation-plugin.la libpam-passthru-plugin.la \
libpassthru-plugin.la libpresence-plugin.la libpwdstorage-plugin.la \
@@ -540,4 +540,11 @@
#------------------------
+# libsampletask-plugin
+#------------------------
+libsampletask_plugin_la_SOURCES = ldap/servers/slapd/test-plugins/sampletask.c
+
+libsampletask_plugin_la_CPPFLAGS = $(PLUGIN_CPPFLAGS)
+
+#------------------------
# libdes-plugin
#-----------------------
3.2 run autotool commands/configure
$ cd <src_root>/ldapserver
$ autogen.sh # make sure there is no errors / warnings
$ mkdir testbuild
$ cd testbuild
$ ../configure --with-fhs [ --prefix=/opt/dirsrv ... ]
$ make install
Plugging the Library Into the Server
------------------------------------
When started, the server loads plug-ins.
1. Stop the server.
Console: Select the server; Object > Stop Server
Command Line: cd [prefix]/usr/lib/<PACKAGE_NAME>/slapd-[serverID] ; ./stop-slapd
2. Add the entry for the server plug-in to
[prefix]/var/lib/slapd-[serverID]/dse.ldif. For example:
dn: cn=[My Server Plugin],cn=plugins,cn=config
objectClass: top
objectClass: nsSlapdPlugin
objectClass: extensibleObject
cn: [My Server Plugin]
nsslapd-pluginPath: [[prefix]/usr/lib/<PACAKGE_NAME>/plugins/myveryown-plugin.so]
nsslapd-pluginInitfunc: [my_plugin_init]
nsslapd-pluginType: [myPluginType]
nsslapd-pluginEnabled: on
nsslapd-pluginarg0: [uid]
nsslapd-pluginarg1: [mail]
nsslapd-pluginarg2: [...]
nsslapd-plugin-depends-on-type: [anotherPluginType]
nsslapd-pluginId: [MyFirstServerPlugin]
nsslapd-pluginVersion: [0.1]
nsslapd-pluginVendor: [Fictional Software Company Incorporated]
nsslapd-pluginDescription: [Add lots of cool functionality]
See the Parameter Block Reference in the Red Hat Directory Server
Plug-In Programmer's Guide for hints on plug-in types.
3. Restart the server.
Console: Object > Start Server
Command Line: cd [prefix]/usr/lib/<PACKAGE_NAME>/slapd-[serverID] ; ./restart-slapd
|