ldaputil.h 7.1 KB

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