README 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # BEGIN COPYRIGHT BLOCK
  2. # Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. # Copyright (C) 2005 Red Hat, Inc.
  4. # All rights reserved.
  5. #
  6. # License: GPL (version 3 or any later version).
  7. # See LICENSE for details.
  8. # END COPYRIGHT BLOCK
  9. #
  10. This directory contains an example program to demonstrate
  11. writing plugins using the "Certificate to LDAP Mapping" API.
  12. Please read the "Managing Servers" manual to find out
  13. about how certificate to ldap mapping can be configured using
  14. the <ServerRoot>/userdb/certmap.conf file. Also refer to the
  15. "Certificate to LDAP Mapping API" documentation to find out
  16. about the various API functions and how you can write your
  17. plugin.
  18. This example demonstrate use of most of the API functions. It
  19. defines a mapping function, a search function, and a verify
  20. function. Read the API doc to learn about these functions.
  21. The init.c file also contains an init function which sets the
  22. mapping, search and verify functions.
  23. The Mapping Function
  24. --------------------
  25. The mapping function extracts the attributes "CN", "E", "O" and
  26. "C" from the certificate's subject DN using the function
  27. ldapu_get_cert_ava_val. If the attributes "C" doesn't exists
  28. then it defaults to "US". It then gets the value of a custom
  29. certmap.conf property "defaultOU" using the function
  30. ldapu_certmap_info_attrval. This demonstrates how you can have
  31. your own custom properties defined in the certmap.conf file.
  32. The mapping function then returns an ldapdn of the form:
  33. "cn=<name>, ou=<defaultOU>, o=<o>, c=<c>".
  34. If the "E" attribute has a value, it returns a filter
  35. "mail=<e>". Finally, the mapping function frees the structures
  36. returned by some of the API functions it called.
  37. The Search Function
  38. -------------------
  39. The search function calls a dummy function to get the
  40. certificate's serial number. It then does a subtree search in
  41. the entire directory for the filter
  42. "certSerialNumber=<serial No.>". If this fails, it calls the
  43. default search function. This demonstrates how you can use the
  44. default functions in your custom functions.
  45. The Verify Function
  46. -------------------
  47. The verify function returns LDAPU_SUCCESS if only one entry was
  48. returned by the search function. Otherwise, it returns
  49. LDAPU_CERT_VERIFY_FUNCTION_FAILED.
  50. Error Reporting
  51. ---------------
  52. To report errors/warning, there is a function defined called
  53. plugin_ereport. This function demonstrates how to get the
  54. subject DN and the issuer DN from the certificate.
  55. Build Procedure
  56. ---------------
  57. On UNIX: Edit the Makefile, and set the variables ARCH & SROOT
  58. according to the comments in the Makefile. Download LDAP C SDK
  59. from the mozilla.org site and make the ldap include
  60. files available in <SROOT>/include. Copy the
  61. ../include/certmap.h file to the <SROOT>/include directory.
  62. Use 'gmake' to build the plugin. A shared library plugin.so
  63. (plugin.sl on HP) will be created in the current directory.
  64. On NT: Execute the following command:
  65. NMAKE /f "Certmap.mak" CFG="Certmap - Win32 Debug"
  66. Certmap.dll will be created in the Debug subdirectory.
  67. Certmap.conf Configuration
  68. --------------------------
  69. Save a copy of certmap.conf file.
  70. Change the certmap.conf file as follows:
  71. certmap default default
  72. default:defaultOU marketing
  73. default:library <path to the shared library>
  74. default:InitFn plugin_init_fn
  75. After experimenting with this example, restore the old copy of
  76. certmap.conf file. Or else, set the certmap.conf file as follows:
  77. certmap default default
  78. default:DNComps
  79. default:FilterComps e, mail, uid
  80. default:VerifyCert on