ldaputil.h 5.1 KB

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