ldaputil.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. #ifndef _LDAPU_LDAPUTIL_H
  42. #define _LDAPU_LDAPUTIL_H
  43. #include <ldaputil/dbconf.h>
  44. #include <ldaputil/certmap.h>
  45. typedef struct ldapu_list_node {
  46. void *info; /* pointer to the corresponding info */
  47. struct ldapu_list_node *next; /* pointer to the next node */
  48. struct ldapu_list_node *prev; /* pointer to the prev node */
  49. } LDAPUListNode_t;
  50. typedef struct ldapu_list {
  51. LDAPUListNode_t *head;
  52. LDAPUListNode_t *tail;
  53. } LDAPUList_t;
  54. typedef struct {
  55. char *prop; /* property name */
  56. char *val; /* value -- only char* supported for now */
  57. } LDAPUPropVal_t;
  58. typedef LDAPUList_t LDAPUPropValList_t;
  59. enum {
  60. COMPS_COMMENTED_OUT,
  61. COMPS_EMPTY,
  62. COMPS_HAS_ATTRS
  63. };
  64. typedef struct {
  65. char *issuerName; /* issuer (symbolic/short) name */
  66. char *issuerDN; /* cert issuer's DN */
  67. LDAPUPropValList_t *propval; /* pointer to the prop-val pairs list */
  68. CertMapFn_t mapfn; /* cert to ldapdn & filter mapping func */
  69. CertVerifyFn_t verifyfn; /* verify cert function */
  70. CertSearchFn_t searchfn; /* search ldap entry function */
  71. long dncomps; /* bitmask: components to form ldap dn */
  72. long filtercomps; /* components used to form ldap filter */
  73. int verifyCert; /* Verify the cert? */
  74. char *searchAttr; /* LDAP attr used by the search fn */
  75. int dncompsState; /* Empty, commented out, or attr names */
  76. int filtercompsState; /* Empty, commented out, or attr names */
  77. } LDAPUCertMapInfo_t;
  78. typedef LDAPUList_t LDAPUCertMapListInfo_t;
  79. typedef void * (*LDAPUListNodeFn_t)(void *info, void *arg);
  80. #ifdef __cplusplus
  81. extern "C" {
  82. #endif
  83. extern int certmap_read_default_certinfo (const char *file);
  84. extern int certmap_read_certconfig_file (const char *file);
  85. extern void ldapu_certinfo_free (void *certmap_info);
  86. extern void ldapu_certmap_listinfo_free (void *certmap_listinfo);
  87. extern void ldapu_propval_list_free (void *propval_list);
  88. NSAPI_PUBLIC extern int ldaputil_exit ();
  89. NSAPI_PUBLIC extern int ldapu_cert_to_user (void *cert, LDAP *ld,
  90. const char *basedn,
  91. LDAPMessage **res,
  92. char **user);
  93. NSAPI_PUBLIC extern int ldapu_certmap_init (const char *config_file,
  94. const char *libname,
  95. LDAPUCertMapListInfo_t **certmap_list,
  96. LDAPUCertMapInfo_t
  97. **certmap_default);
  98. NSAPI_PUBLIC extern int ldapu_certinfo_modify (const char *issuerName,
  99. const char *issuerDN,
  100. const LDAPUPropValList_t *propval);
  101. NSAPI_PUBLIC extern int ldapu_certinfo_delete (const char *issuerDN);
  102. NSAPI_PUBLIC extern int ldapu_certinfo_save (const char *fname,
  103. const char *old_fname,
  104. const char *tmp_fname);
  105. NSAPI_PUBLIC extern int ldapu_list_alloc (LDAPUList_t **list);
  106. NSAPI_PUBLIC extern int ldapu_propval_alloc (const char *prop, const char *val,
  107. LDAPUPropVal_t **propval);
  108. NSAPI_PUBLIC extern int ldapu_list_add_info (LDAPUList_t *list, void *info);
  109. #ifndef DONT_USE_LDAP_SSL
  110. #define USE_LDAP_SSL
  111. #endif
  112. #ifndef LDAP_CALL
  113. #define LDAP_CALL
  114. #endif
  115. #ifndef LDAP_CALLBACK
  116. #define LDAP_CALLBACK
  117. #endif
  118. typedef struct {
  119. #ifdef USE_LDAP_SSL
  120. LDAP* (LDAP_CALL LDAP_CALLBACK *ldapuV_ssl_init) ( const char*, int, int );
  121. #else
  122. LDAP* (LDAP_CALL LDAP_CALLBACK *ldapuV_init) ( const char*, int );
  123. #endif
  124. int (LDAP_CALL LDAP_CALLBACK *ldapuV_set_option) ( LDAP*, int, const void* );
  125. int (LDAP_CALL LDAP_CALLBACK *ldapuV_simple_bind_s) ( LDAP*, const char*, const char* );
  126. int (LDAP_CALL LDAP_CALLBACK *ldapuV_unbind) ( LDAP* );
  127. int (LDAP_CALL LDAP_CALLBACK *ldapuV_search_s) ( LDAP*, const char*, int, const char*, char**, int, LDAPMessage** );
  128. int (LDAP_CALL LDAP_CALLBACK *ldapuV_count_entries) ( LDAP*, LDAPMessage* );
  129. LDAPMessage*(LDAP_CALL LDAP_CALLBACK *ldapuV_first_entry) ( LDAP*, LDAPMessage* );
  130. LDAPMessage*(LDAP_CALL LDAP_CALLBACK *ldapuV_next_entry) ( LDAP*, LDAPMessage* );
  131. int (LDAP_CALL LDAP_CALLBACK *ldapuV_msgfree) ( LDAP*, LDAPMessage* );
  132. char* (LDAP_CALL LDAP_CALLBACK *ldapuV_get_dn) ( LDAP*, LDAPMessage* );
  133. void (LDAP_CALL LDAP_CALLBACK *ldapuV_memfree) ( LDAP*, void* );
  134. char* (LDAP_CALL LDAP_CALLBACK *ldapuV_first_attribute) ( LDAP*, LDAPMessage*, BerElement** );
  135. char* (LDAP_CALL LDAP_CALLBACK *ldapuV_next_attribute) ( LDAP*, LDAPMessage*, BerElement* );
  136. void (LDAP_CALL LDAP_CALLBACK *ldapuV_ber_free) ( LDAP*, BerElement*, int );
  137. char** (LDAP_CALL LDAP_CALLBACK *ldapuV_get_values) ( LDAP*, LDAPMessage*, const char* );
  138. void (LDAP_CALL LDAP_CALLBACK *ldapuV_value_free) ( LDAP*, char** );
  139. struct berval**(LDAP_CALL LDAP_CALLBACK *ldapuV_get_values_len)( LDAP*, LDAPMessage*, const char* );
  140. void (LDAP_CALL LDAP_CALLBACK *ldapuV_value_free_len)( LDAP*, struct berval** );
  141. } LDAPUVTable_t;
  142. NSAPI_PUBLIC extern void ldapu_VTable_set (LDAPUVTable_t*);
  143. #ifdef __cplusplus
  144. }
  145. #endif
  146. #endif /* _LDAPU_LDAPUTIL_H */