00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00022 #ifndef UTIL_LDAP_H
00023 #define UTIL_LDAP_H
00024
00025
00026 #include "apr.h"
00027 #include "apr_thread_mutex.h"
00028 #include "apr_thread_rwlock.h"
00029 #include "apr_tables.h"
00030 #include "apr_time.h"
00031 #include "apr_ldap.h"
00032
00033 #if APR_HAS_SHARED_MEMORY
00034 #include "apr_rmm.h"
00035 #include "apr_shm.h"
00036 #endif
00037
00038
00039 #if APR_HAS_LDAP
00040
00041
00042 #include "ap_config.h"
00043 #include "httpd.h"
00044 #include "http_config.h"
00045 #include "http_core.h"
00046 #include "http_log.h"
00047 #include "http_protocol.h"
00048 #include "http_request.h"
00049 #include "apr_optional.h"
00050
00051
00052
00053
00054 #if !defined(WIN32)
00055 #define LDAP_DECLARE(type) type
00056 #define LDAP_DECLARE_NONSTD(type) type
00057 #define LDAP_DECLARE_DATA
00058 #elif defined(LDAP_DECLARE_STATIC)
00059 #define LDAP_DECLARE(type) type __stdcall
00060 #define LDAP_DECLARE_NONSTD(type) type
00061 #define LDAP_DECLARE_DATA
00062 #elif defined(LDAP_DECLARE_EXPORT)
00063 #define LDAP_DECLARE(type) __declspec(dllexport) type __stdcall
00064 #define LDAP_DECLARE_NONSTD(type) __declspec(dllexport) type
00065 #define LDAP_DECLARE_DATA __declspec(dllexport)
00066 #else
00067 #define LDAP_DECLARE(type) __declspec(dllimport) type __stdcall
00068 #define LDAP_DECLARE_NONSTD(type) __declspec(dllimport) type
00069 #define LDAP_DECLARE_DATA __declspec(dllimport)
00070 #endif
00071
00072
00073
00074
00075
00076
00077 typedef enum {
00078 never=LDAP_DEREF_NEVER,
00079 searching=LDAP_DEREF_SEARCHING,
00080 finding=LDAP_DEREF_FINDING,
00081 always=LDAP_DEREF_ALWAYS
00082 } deref_options;
00083
00084
00085 typedef struct util_ldap_connection_t {
00086 LDAP *ldap;
00087 apr_pool_t *pool;
00088 #if APR_HAS_THREADS
00089 apr_thread_mutex_t *lock;
00090 #endif
00091 int bound;
00092
00093 const char *host;
00094 int port;
00095 deref_options deref;
00096
00097 const char *binddn;
00098 const char *bindpw;
00099
00100 int secure;
00101 apr_array_header_t *client_certs;
00102
00103 const char *reason;
00104
00105 struct util_ldap_connection_t *next;
00106 } util_ldap_connection_t;
00107
00108
00109 typedef struct util_ldap_state_t {
00110 apr_pool_t *pool;
00111 #if APR_HAS_THREADS
00112 apr_thread_mutex_t *mutex;
00113 #endif
00114 apr_global_mutex_t *util_ldap_cache_lock;
00115
00116 apr_size_t cache_bytes;
00117 char *cache_file;
00118 long search_cache_ttl;
00119 long search_cache_size;
00120 long compare_cache_ttl;
00121 long compare_cache_size;
00122
00123 struct util_ldap_connection_t *connections;
00124 int ssl_supported;
00125 apr_array_header_t *global_certs;
00126 apr_array_header_t *client_certs;
00127 int secure;
00128 int secure_set;
00129
00130 #if APR_HAS_SHARED_MEMORY
00131 apr_shm_t *cache_shm;
00132 apr_rmm_t *cache_rmm;
00133 #endif
00134
00135
00136 void *util_ldap_cache;
00137 char *lock_file;
00138 long connectionTimeout;
00139 int verify_svr_cert;
00140
00141 } util_ldap_state_t;
00142
00143
00156 APR_DECLARE_OPTIONAL_FN(int,uldap_connection_open,(request_rec *r,
00157 util_ldap_connection_t *ldc));
00158
00168 APR_DECLARE_OPTIONAL_FN(void,uldap_connection_close,(util_ldap_connection_t *ldc));
00169
00179 APR_DECLARE_OPTIONAL_FN(apr_status_t,uldap_connection_unbind,(void *param));
00180
00189 APR_DECLARE_OPTIONAL_FN(apr_status_t,uldap_connection_cleanup,(void *param));
00190
00208 APR_DECLARE_OPTIONAL_FN(util_ldap_connection_t *,uldap_connection_find,(request_rec *r, const char *host, int port,
00209 const char *binddn, const char *bindpw, deref_options deref,
00210 int secure));
00211
00230 APR_DECLARE_OPTIONAL_FN(int,uldap_cache_comparedn,(request_rec *r, util_ldap_connection_t *ldc,
00231 const char *url, const char *dn, const char *reqdn,
00232 int compare_dn_on_server));
00233
00247 APR_DECLARE_OPTIONAL_FN(int,uldap_cache_compare,(request_rec *r, util_ldap_connection_t *ldc,
00248 const char *url, const char *dn, const char *attrib, const char *value));
00249
00269 APR_DECLARE_OPTIONAL_FN(int,uldap_cache_checkuserid,(request_rec *r, util_ldap_connection_t *ldc,
00270 const char *url, const char *basedn, int scope, char **attrs,
00271 const char *filter, const char *bindpw, const char **binddn, const char ***retvals));
00272
00291 APR_DECLARE_OPTIONAL_FN(int,uldap_cache_getuserdn,(request_rec *r, util_ldap_connection_t *ldc,
00292 const char *url, const char *basedn, int scope, char **attrs,
00293 const char *filter, const char **binddn, const char ***retvals));
00294
00299 APR_DECLARE_OPTIONAL_FN(int,uldap_ssl_supported,(request_rec *r));
00300
00301
00302
00314 apr_status_t util_ldap_cache_init(apr_pool_t *pool, util_ldap_state_t *st);
00315
00316
00317
00325 char *util_ald_cache_display(request_rec *r, util_ldap_state_t *st);
00326
00327 #endif
00328 #endif