README 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. # BEGIN COPYRIGHT BLOCK
  2. # This Program is free software; you can redistribute it and/or modify it under
  3. # the terms of the GNU General Public License as published by the Free Software
  4. # Foundation; version 2 of the License.
  5. #
  6. # This Program is distributed in the hope that it will be useful, but WITHOUT
  7. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. #
  10. # You should have received a copy of the GNU General Public License along with
  11. # this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. # Place, Suite 330, Boston, MA 02111-1307 USA.
  13. #
  14. # In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. # right to link the code of this Program with code not covered under the GNU
  16. # General Public License ("Non-GPL Code") and to distribute linked combinations
  17. # including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. # permitted under this exception must only link to the code of this Program
  19. # through those well defined interfaces identified in the file named EXCEPTION
  20. # found in the source code files (the "Approved Interfaces"). The files of
  21. # Non-GPL Code may instantiate templates or use macros or inline functions from
  22. # the Approved Interfaces without causing the resulting work to be covered by
  23. # the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. # additions to the list of Approved Interfaces. You must obey the GNU General
  25. # Public License in all respects for all of the Program code and other code used
  26. # in conjunction with the Program except the Non-GPL Code covered by this
  27. # exception. If you modify this file, you may extend this exception to your
  28. # version of the file, but you are not obligated to do so. If you do not wish to
  29. # provide this exception without modification, you must delete this exception
  30. # statement from your version and license this file solely under the GPL without
  31. # exception.
  32. #
  33. #
  34. # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. # Copyright (C) 2005 Red Hat, Inc.
  36. # All rights reserved.
  37. # END COPYRIGHT BLOCK
  38. #
  39. ----------------------------
  40. Sample Server Plug-Ins
  41. for Directory Server 7
  42. ----------------------------
  43. This directory contains code for some sample server plug-ins intended for
  44. use with the Fedora Directory Server 7.
  45. NOTE: Before you compile and run these examples, make sure
  46. to change any server-specific data in the examples to
  47. values applicable to your Directory Server.
  48. testbind.c
  49. ----------
  50. This is an example of a pre-operation bind plug-in function that
  51. handles authentication. When processing an LDAP bind request, the
  52. server calls this plug-in function before calling the database bind
  53. function.
  54. testentry.c
  55. -----------
  56. This is an example of an entry store plug-in function and an entry fetch
  57. plug-in function. You must be using the default database (not your own
  58. back-end database) in order for these plug-in functions to work.
  59. testextendedop.c
  60. ----------------
  61. This is an example of an extended operation plug-in function that
  62. handles requests for the extended operation with the OID 1.2.3.4.
  63. The example should be used in conjunction with the reqextop.c and
  64. ReqExtOp.java clients (the source code for these clients is located
  65. in the clients subdirectory). These clients are capable of requesting
  66. the extended operation with the OID 1.2.3.4.
  67. testpostop.c
  68. ------------
  69. This contains examples of post-operation plug-in functions. These
  70. functions are called after the server processes LDAP operations.
  71. The functions log changes to the directory in a change log file.
  72. testpreop.c
  73. -----------
  74. This contains examples of pre-operation plug-in functions. These
  75. functions are called before the server processes LDAP operations.
  76. testsaslbind.c
  77. --------------
  78. This is an example of a pre-operation plug-in function that
  79. implements a SASL mechanism.
  80. clients
  81. -------
  82. This directory contains the C and Java source code for clients
  83. that you can use to test the server plug-ins. See the README
  84. file in that directory for details.
  85. ----------------------------
  86. How To Create
  87. A Server Plug-In
  88. ----------------------------
  89. Text between brackets ([]) should be replaced with values specific to
  90. your situation.
  91. Creating the Plug-In Library
  92. ----------------------------
  93. Server plug-ins are built as libraries available to the server.
  94. 1. Include the Plug-In API. For example:
  95. #include "[serverRoot]/plugins/slapd/slapi/include/slapi-plugin.h"
  96. 2. Write your plug-in, including a top level initialization function
  97. used by the server to start the plug-in. For example:
  98. /* Plug-in functions defined here */
  99. int my_plugin_init( Slapi_PBlock *pb ) /* initialize param. block */
  100. {
  101. /* Set or get the parameters in pb */
  102. slapi_pblock_set();
  103. slapi_pblock_get();
  104. /* Plug-in functions registered here */
  105. if (error)
  106. {
  107. slapi_log_error();
  108. return error_code;
  109. }
  110. else return 0;
  111. } /* my_plugin_init() */
  112. See the Parameter Block Reference in the Netscape Directory Server
  113. Plug-In Programmer's Guide for hints on plug-in types.
  114. 3. Build the plug-in as a library.
  115. We recommend you copy and adapt the Makefile in
  116. [serverRoot]/plugins/slapd/slapi/examples.
  117. Plugging the Library Into the Server
  118. ------------------------------------
  119. When started, the server loads plug-ins.
  120. 1. Stop the server.
  121. Console: Select the server; Object > Stop Server
  122. Command Line: cd [serverRoot]/slapd-[serverID] ; ./stop-slapd
  123. 2. Add the entry for the server plug-in to
  124. [serverRoot]/slapd-[serverID]/config/dse.ldif. For example:
  125. dn: cn=[My Server Plugin],cn=plugins,cn=config
  126. objectClass: top
  127. objectClass: nsSlapdPlugin
  128. objectClass: extensibleObject
  129. cn: [My Server Plugin]
  130. nsslapd-pluginPath: [[serverRoot]/myPlugins/myveryown-plugin.so]
  131. nsslapd-pluginInitfunc: [my_plugin_init]
  132. nsslapd-pluginType: [myPluginType]
  133. nsslapd-pluginEnabled: on
  134. nsslapd-pluginarg0: [uid]
  135. nsslapd-pluginarg1: [mail]
  136. nsslapd-pluginarg2: [...]
  137. nsslapd-plugin-depends-on-type: [anotherPluginType]
  138. nsslapd-pluginId: [MyFirstServerPlugin]
  139. nsslapd-pluginVersion: [0.1]
  140. nsslapd-pluginVendor: [Fictional Software Company Incorporated]
  141. nsslapd-pluginDescription: [Add lots of cool functionality]
  142. See the Parameter Block Reference in the Netscape Directory Server
  143. Plug-In Programmer's Guide for hints on plug-in types.
  144. 3. Restart the server.
  145. Console: Object > Start Server
  146. Command Line: cd [serverRoot]/slapd-[serverID] ; ./restart-slapd