ldaputil.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. #ifdef HAVE_CONFIG_H
  10. #include <config.h>
  11. #endif
  12. #ifndef _LDAPU_LDAPUTIL_H
  13. #define _LDAPU_LDAPUTIL_H
  14. #include <ldaputil/dbconf.h>
  15. #include <ldaputil/certmap.h>
  16. typedef struct ldapu_list_node
  17. {
  18. void *info; /* pointer to the corresponding info */
  19. struct ldapu_list_node *next; /* pointer to the next node */
  20. struct ldapu_list_node *prev; /* pointer to the prev node */
  21. } LDAPUListNode_t;
  22. typedef struct ldapu_list
  23. {
  24. LDAPUListNode_t *head;
  25. LDAPUListNode_t *tail;
  26. } LDAPUList_t;
  27. typedef struct
  28. {
  29. char *prop; /* property name */
  30. char *val; /* value -- only char* supported for now */
  31. } LDAPUPropVal_t;
  32. typedef LDAPUList_t LDAPUPropValList_t;
  33. enum
  34. {
  35. COMPS_COMMENTED_OUT,
  36. COMPS_EMPTY,
  37. COMPS_HAS_ATTRS
  38. };
  39. typedef struct
  40. {
  41. char *issuerName; /* issuer (symbolic/short) name */
  42. CERTName *issuerDN; /* cert issuer's DN */
  43. LDAPUPropValList_t *propval; /* pointer to the prop-val pairs list */
  44. CertMapFn_t mapfn; /* cert to ldapdn & filter mapping func */
  45. CertVerifyFn_t verifyfn; /* verify cert function */
  46. CertSearchFn_t searchfn; /* search ldap entry function */
  47. long dncomps; /* bitmask: components to form ldap dn */
  48. long filtercomps; /* components used to form ldap filter */
  49. int verifyCert; /* Verify the cert? */
  50. char *searchAttr; /* LDAP attr used by the search fn */
  51. int dncompsState; /* Empty, commented out, or attr names */
  52. int filtercompsState; /* Empty, commented out, or attr names */
  53. } LDAPUCertMapInfo_t;
  54. typedef LDAPUList_t LDAPUCertMapListInfo_t;
  55. typedef void *(*LDAPUListNodeFn_t)(void *info, void *arg);
  56. #ifdef __cplusplus
  57. extern "C" {
  58. #endif
  59. extern int certmap_read_default_certinfo(const char *file);
  60. extern int certmap_read_certconfig_file(const char *file);
  61. extern void ldapu_certinfo_free(void *certmap_info);
  62. extern void ldapu_certmap_listinfo_free(void *certmap_listinfo);
  63. extern void ldapu_propval_list_free(void *propval_list);
  64. NSAPI_PUBLIC extern int ldaputil_exit(void);
  65. NSAPI_PUBLIC extern int ldapu_cert_to_user(void *cert, LDAP *ld, const char *basedn, LDAPMessage **res, char **user);
  66. NSAPI_PUBLIC extern int ldapu_certmap_init(const char *config_file,
  67. const char *libname,
  68. LDAPUCertMapListInfo_t **certmap_list,
  69. LDAPUCertMapInfo_t
  70. **certmap_default);
  71. NSAPI_PUBLIC extern int ldapu_list_alloc(LDAPUList_t **list);
  72. NSAPI_PUBLIC extern int ldapu_propval_alloc(const char *prop, const char *val, LDAPUPropVal_t **propval);
  73. NSAPI_PUBLIC extern int ldapu_list_add_info(LDAPUList_t *list, void *info);
  74. #ifndef DONT_USE_LDAP_SSL
  75. #define USE_LDAP_SSL
  76. #endif
  77. #ifndef LDAP_CALL
  78. #define LDAP_CALL
  79. #endif
  80. #ifndef LDAP_CALLBACK
  81. #define LDAP_CALLBACK
  82. #endif
  83. typedef struct
  84. {
  85. #ifdef USE_LDAP_SSL
  86. LDAP *(LDAP_CALL LDAP_CALLBACK *ldapuV_ssl_init)(const char *, int, int);
  87. #else
  88. LDAP *(LDAP_CALL LDAP_CALLBACK *ldapuV_init)(const char *, int);
  89. #endif
  90. int(LDAP_CALL LDAP_CALLBACK *ldapuV_set_option)(LDAP *, int, const void *);
  91. int(LDAP_CALL LDAP_CALLBACK *ldapuV_simple_bind_s)(LDAP *, const char *, const char *);
  92. int(LDAP_CALL LDAP_CALLBACK *ldapuV_unbind)(LDAP *);
  93. int(LDAP_CALL LDAP_CALLBACK *ldapuV_search_s)(LDAP *, const char *, int, const char *, char **, int, LDAPMessage **);
  94. int(LDAP_CALL LDAP_CALLBACK *ldapuV_count_entries)(LDAP *, LDAPMessage *);
  95. LDAPMessage *(LDAP_CALL LDAP_CALLBACK *ldapuV_first_entry)(LDAP *, LDAPMessage *);
  96. LDAPMessage *(LDAP_CALL LDAP_CALLBACK *ldapuV_next_entry)(LDAP *, LDAPMessage *);
  97. int(LDAP_CALL LDAP_CALLBACK *ldapuV_msgfree)(LDAP *, LDAPMessage *);
  98. char *(LDAP_CALL LDAP_CALLBACK *ldapuV_get_dn)(LDAP *, LDAPMessage *);
  99. void(LDAP_CALL LDAP_CALLBACK *ldapuV_memfree)(LDAP *, void *);
  100. char *(LDAP_CALL LDAP_CALLBACK *ldapuV_first_attribute)(LDAP *, LDAPMessage *, BerElement **);
  101. char *(LDAP_CALL LDAP_CALLBACK *ldapuV_next_attribute)(LDAP *, LDAPMessage *, BerElement *);
  102. void(LDAP_CALL LDAP_CALLBACK *ldapuV_ber_free)(LDAP *, BerElement *, int);
  103. char **(LDAP_CALL LDAP_CALLBACK *ldapuV_get_values)(LDAP *, LDAPMessage *, const char *);
  104. void(LDAP_CALL LDAP_CALLBACK *ldapuV_value_free)(LDAP *, char **);
  105. struct berval **(LDAP_CALL LDAP_CALLBACK *ldapuV_get_values_len)(LDAP *, LDAPMessage *, const char *);
  106. void(LDAP_CALL LDAP_CALLBACK *ldapuV_value_free_len)(LDAP *, struct berval **);
  107. } LDAPUVTable_t;
  108. NSAPI_PUBLIC extern void ldapu_VTable_set(LDAPUVTable_t *);
  109. #ifdef __cplusplus
  110. }
  111. #endif
  112. #endif /* _LDAPU_LDAPUTIL_H */