1 /* back-ldap.h - ldap backend header file */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1999-2015 The OpenLDAP Foundation.
6 * Portions Copyright 2000-2003 Pierangelo Masarati.
7 * Portions Copyright 1999-2003 Howard Chu.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted only as authorized by the OpenLDAP
14 * A copy of this license is available in the file LICENSE in the
15 * top-level directory of the distribution or, alternatively, at
16 * <http://www.OpenLDAP.org/license.html>.
19 * This work was initially developed by the Howard Chu for inclusion
20 * in OpenLDAP Software and subsequently enhanced by Pierangelo
27 #include "../back-monitor/back-monitor.h"
33 /* stuff required for monitoring */
34 typedef struct ldap_monitor_info_t {
35 monitor_subsys_t lmi_mss[2];
37 struct berval lmi_ndn;
38 struct berval lmi_conn_rdn;
39 struct berval lmi_ops_rdn;
40 } ldap_monitor_info_t;
43 /* even numbers are connection types */
44 LDAP_BACK_PCONN_FIRST = 0,
45 LDAP_BACK_PCONN_ROOTDN = LDAP_BACK_PCONN_FIRST,
46 LDAP_BACK_PCONN_ANON = 2,
47 LDAP_BACK_PCONN_BIND = 4,
50 LDAP_BACK_PCONN_TLS = 0x1U,
52 LDAP_BACK_PCONN_ROOTDN_TLS = (LDAP_BACK_PCONN_ROOTDN|LDAP_BACK_PCONN_TLS),
53 LDAP_BACK_PCONN_ANON_TLS = (LDAP_BACK_PCONN_ANON|LDAP_BACK_PCONN_TLS),
54 LDAP_BACK_PCONN_BIND_TLS = (LDAP_BACK_PCONN_BIND|LDAP_BACK_PCONN_TLS),
59 typedef struct ldapconn_base_t {
61 #define LDAP_BACK_CONN2PRIV(lc) ((unsigned long)(lc)->lc_conn)
62 #define LDAP_BACK_PCONN_ISPRIV(lc) (((void *)(lc)->lc_conn) >= ((void *)LDAP_BACK_PCONN_FIRST) \
63 && ((void *)(lc)->lc_conn) < ((void *)LDAP_BACK_PCONN_LAST))
64 #define LDAP_BACK_PCONN_ISROOTDN(lc) (LDAP_BACK_PCONN_ISPRIV((lc)) \
65 && (LDAP_BACK_CONN2PRIV((lc)) < LDAP_BACK_PCONN_ANON))
66 #define LDAP_BACK_PCONN_ISANON(lc) (LDAP_BACK_PCONN_ISPRIV((lc)) \
67 && (LDAP_BACK_CONN2PRIV((lc)) < LDAP_BACK_PCONN_BIND) \
68 && (LDAP_BACK_CONN2PRIV((lc)) >= LDAP_BACK_PCONN_ANON))
69 #define LDAP_BACK_PCONN_ISBIND(lc) (LDAP_BACK_PCONN_ISPRIV((lc)) \
70 && (LDAP_BACK_CONN2PRIV((lc)) >= LDAP_BACK_PCONN_BIND))
71 #define LDAP_BACK_PCONN_ISTLS(lc) (LDAP_BACK_PCONN_ISPRIV((lc)) \
72 && (LDAP_BACK_CONN2PRIV((lc)) & LDAP_BACK_PCONN_TLS))
74 #define LDAP_BACK_PCONN_ROOTDN_SET(lc, op) \
75 ((lc)->lc_conn = (void *)((op)->o_conn->c_is_tls ? (void *) LDAP_BACK_PCONN_ROOTDN_TLS : (void *) LDAP_BACK_PCONN_ROOTDN))
76 #define LDAP_BACK_PCONN_ANON_SET(lc, op) \
77 ((lc)->lc_conn = (void *)((op)->o_conn->c_is_tls ? (void *) LDAP_BACK_PCONN_ANON_TLS : (void *) LDAP_BACK_PCONN_ANON))
78 #define LDAP_BACK_PCONN_BIND_SET(lc, op) \
79 ((lc)->lc_conn = (void *)((op)->o_conn->c_is_tls ? (void *) LDAP_BACK_PCONN_BIND_TLS : (void *) LDAP_BACK_PCONN_BIND))
80 #else /* ! HAVE_TLS */
81 #define LDAP_BACK_PCONN_ROOTDN_SET(lc, op) \
82 ((lc)->lc_conn = (void *)LDAP_BACK_PCONN_ROOTDN)
83 #define LDAP_BACK_PCONN_ANON_SET(lc, op) \
84 ((lc)->lc_conn = (void *)LDAP_BACK_PCONN_ANON)
85 #define LDAP_BACK_PCONN_BIND_SET(lc, op) \
86 ((lc)->lc_conn = (void *)LDAP_BACK_PCONN_BIND)
87 #endif /* ! HAVE_TLS */
88 #define LDAP_BACK_PCONN_SET(lc, op) \
89 (BER_BVISEMPTY(&(op)->o_ndn) ? \
90 LDAP_BACK_PCONN_ANON_SET((lc), (op)) : LDAP_BACK_PCONN_ROOTDN_SET((lc), (op)))
92 struct berval lcb_local_ndn;
94 time_t lcb_create_time;
98 typedef struct ldapconn_t {
99 ldapconn_base_t lc_base;
100 #define lc_conn lc_base.lcb_conn
101 #define lc_local_ndn lc_base.lcb_local_ndn
102 #define lc_refcnt lc_base.lcb_refcnt
103 #define lc_create_time lc_base.lcb_create_time
104 #define lc_time lc_base.lcb_time
106 LDAP_TAILQ_ENTRY(ldapconn_t) lc_q;
109 #define LDAP_BACK_CONN_ISSET_F(fp,f) (*(fp) & (f))
110 #define LDAP_BACK_CONN_SET_F(fp,f) (*(fp) |= (f))
111 #define LDAP_BACK_CONN_CLEAR_F(fp,f) (*(fp) &= ~(f))
112 #define LDAP_BACK_CONN_CPY_F(fp,f,mfp) \
114 if ( ((f) & *(mfp)) == (f) ) { \
121 #define LDAP_BACK_CONN_ISSET(lc,f) LDAP_BACK_CONN_ISSET_F(&(lc)->lc_lcflags, (f))
122 #define LDAP_BACK_CONN_SET(lc,f) LDAP_BACK_CONN_SET_F(&(lc)->lc_lcflags, (f))
123 #define LDAP_BACK_CONN_CLEAR(lc,f) LDAP_BACK_CONN_CLEAR_F(&(lc)->lc_lcflags, (f))
124 #define LDAP_BACK_CONN_CPY(lc,f,mlc) LDAP_BACK_CONN_CPY_F(&(lc)->lc_lcflags, (f), &(mlc)->lc_lcflags)
126 /* 0xFFF00000U are reserved for back-meta */
128 #define LDAP_BACK_FCONN_ISBOUND (0x00000001U)
129 #define LDAP_BACK_FCONN_ISANON (0x00000002U)
130 #define LDAP_BACK_FCONN_ISBMASK (LDAP_BACK_FCONN_ISBOUND|LDAP_BACK_FCONN_ISANON)
131 #define LDAP_BACK_FCONN_ISPRIV (0x00000004U)
132 #define LDAP_BACK_FCONN_ISTLS (0x00000008U)
133 #define LDAP_BACK_FCONN_BINDING (0x00000010U)
134 #define LDAP_BACK_FCONN_TAINTED (0x00000020U)
135 #define LDAP_BACK_FCONN_ABANDON (0x00000040U)
136 #define LDAP_BACK_FCONN_ISIDASR (0x00000080U)
137 #define LDAP_BACK_FCONN_CACHED (0x00000100U)
139 #define LDAP_BACK_CONN_ISBOUND(lc) LDAP_BACK_CONN_ISSET((lc), LDAP_BACK_FCONN_ISBOUND)
140 #define LDAP_BACK_CONN_ISBOUND_SET(lc) LDAP_BACK_CONN_SET((lc), LDAP_BACK_FCONN_ISBOUND)
141 #define LDAP_BACK_CONN_ISBOUND_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), LDAP_BACK_FCONN_ISBMASK)
142 #define LDAP_BACK_CONN_ISBOUND_CPY(lc, mlc) LDAP_BACK_CONN_CPY((lc), LDAP_BACK_FCONN_ISBOUND, (mlc))
143 #define LDAP_BACK_CONN_ISANON(lc) LDAP_BACK_CONN_ISSET((lc), LDAP_BACK_FCONN_ISANON)
144 #define LDAP_BACK_CONN_ISANON_SET(lc) LDAP_BACK_CONN_SET((lc), LDAP_BACK_FCONN_ISANON)
145 #define LDAP_BACK_CONN_ISANON_CLEAR(lc) LDAP_BACK_CONN_ISBOUND_CLEAR((lc))
146 #define LDAP_BACK_CONN_ISANON_CPY(lc, mlc) LDAP_BACK_CONN_CPY((lc), LDAP_BACK_FCONN_ISANON, (mlc))
147 #define LDAP_BACK_CONN_ISPRIV(lc) LDAP_BACK_CONN_ISSET((lc), LDAP_BACK_FCONN_ISPRIV)
148 #define LDAP_BACK_CONN_ISPRIV_SET(lc) LDAP_BACK_CONN_SET((lc), LDAP_BACK_FCONN_ISPRIV)
149 #define LDAP_BACK_CONN_ISPRIV_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), LDAP_BACK_FCONN_ISPRIV)
150 #define LDAP_BACK_CONN_ISPRIV_CPY(lc, mlc) LDAP_BACK_CONN_CPY((lc), LDAP_BACK_FCONN_ISPRIV, (mlc))
151 #define LDAP_BACK_CONN_ISTLS(lc) LDAP_BACK_CONN_ISSET((lc), LDAP_BACK_FCONN_ISTLS)
152 #define LDAP_BACK_CONN_ISTLS_SET(lc) LDAP_BACK_CONN_SET((lc), LDAP_BACK_FCONN_ISTLS)
153 #define LDAP_BACK_CONN_ISTLS_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), LDAP_BACK_FCONN_ISTLS)
154 #define LDAP_BACK_CONN_ISTLS_CPY(lc, mlc) LDAP_BACK_CONN_CPY((lc), LDAP_BACK_FCONN_ISTLS, (mlc))
155 #define LDAP_BACK_CONN_BINDING(lc) LDAP_BACK_CONN_ISSET((lc), LDAP_BACK_FCONN_BINDING)
156 #define LDAP_BACK_CONN_BINDING_SET(lc) LDAP_BACK_CONN_SET((lc), LDAP_BACK_FCONN_BINDING)
157 #define LDAP_BACK_CONN_BINDING_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), LDAP_BACK_FCONN_BINDING)
158 #define LDAP_BACK_CONN_TAINTED(lc) LDAP_BACK_CONN_ISSET((lc), LDAP_BACK_FCONN_TAINTED)
159 #define LDAP_BACK_CONN_TAINTED_SET(lc) LDAP_BACK_CONN_SET((lc), LDAP_BACK_FCONN_TAINTED)
160 #define LDAP_BACK_CONN_TAINTED_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), LDAP_BACK_FCONN_TAINTED)
161 #define LDAP_BACK_CONN_ABANDON(lc) LDAP_BACK_CONN_ISSET((lc), LDAP_BACK_FCONN_ABANDON)
162 #define LDAP_BACK_CONN_ABANDON_SET(lc) LDAP_BACK_CONN_SET((lc), LDAP_BACK_FCONN_ABANDON)
163 #define LDAP_BACK_CONN_ABANDON_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), LDAP_BACK_FCONN_ABANDON)
164 #define LDAP_BACK_CONN_ISIDASSERT(lc) LDAP_BACK_CONN_ISSET((lc), LDAP_BACK_FCONN_ISIDASR)
165 #define LDAP_BACK_CONN_ISIDASSERT_SET(lc) LDAP_BACK_CONN_SET((lc), LDAP_BACK_FCONN_ISIDASR)
166 #define LDAP_BACK_CONN_ISIDASSERT_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), LDAP_BACK_FCONN_ISIDASR)
167 #define LDAP_BACK_CONN_ISIDASSERT_CPY(lc, mlc) LDAP_BACK_CONN_CPY((lc), LDAP_BACK_FCONN_ISIDASR, (mlc))
168 #define LDAP_BACK_CONN_CACHED(lc) LDAP_BACK_CONN_ISSET((lc), LDAP_BACK_FCONN_CACHED)
169 #define LDAP_BACK_CONN_CACHED_SET(lc) LDAP_BACK_CONN_SET((lc), LDAP_BACK_FCONN_CACHED)
170 #define LDAP_BACK_CONN_CACHED_CLEAR(lc) LDAP_BACK_CONN_CLEAR((lc), LDAP_BACK_FCONN_CACHED)
173 unsigned long lc_connid;
174 struct berval lc_cred;
175 struct berval lc_bound_ndn;
179 typedef struct ldap_avl_info_t {
180 ldap_pvt_thread_mutex_t lai_mutex;
184 typedef struct slap_retry_info_t {
191 #define SLAP_RETRYNUM_FOREVER (-1) /* retry forever */
192 #define SLAP_RETRYNUM_TAIL (-2) /* end of retrynum array */
193 #define SLAP_RETRYNUM_VALID(n) ((n) >= SLAP_RETRYNUM_FOREVER) /* valid retrynum */
194 #define SLAP_RETRYNUM_FINITE(n) ((n) > SLAP_RETRYNUM_FOREVER) /* not forever */
198 * identity assertion modes
201 LDAP_BACK_IDASSERT_LEGACY = 1,
202 LDAP_BACK_IDASSERT_NOASSERT,
203 LDAP_BACK_IDASSERT_ANONYMOUS,
204 LDAP_BACK_IDASSERT_SELF,
205 LDAP_BACK_IDASSERT_OTHERDN,
206 LDAP_BACK_IDASSERT_OTHERID
207 } slap_idassert_mode_t;
209 /* ID assert stuff */
210 typedef struct slap_idassert_t {
211 slap_idassert_mode_t si_mode;
212 #define li_idassert_mode li_idassert.si_mode
215 #define li_idassert_authcID li_idassert.si_bc.sb_authcId
216 #define li_idassert_authcDN li_idassert.si_bc.sb_binddn
217 #define li_idassert_passwd li_idassert.si_bc.sb_cred
218 #define li_idassert_authzID li_idassert.si_bc.sb_authzId
219 #define li_idassert_authmethod li_idassert.si_bc.sb_method
220 #define li_idassert_sasl_mech li_idassert.si_bc.sb_saslmech
221 #define li_idassert_sasl_realm li_idassert.si_bc.sb_realm
222 #define li_idassert_secprops li_idassert.si_bc.sb_secprops
223 #define li_idassert_tls li_idassert.si_bc.sb_tls
226 #define LDAP_BACK_AUTH_NONE (0x00U)
227 #define LDAP_BACK_AUTH_NATIVE_AUTHZ (0x01U)
228 #define LDAP_BACK_AUTH_OVERRIDE (0x02U)
229 #define LDAP_BACK_AUTH_PRESCRIPTIVE (0x04U)
230 #define LDAP_BACK_AUTH_OBSOLETE_PROXY_AUTHZ (0x08U)
231 #define LDAP_BACK_AUTH_OBSOLETE_ENCODING_WORKAROUND (0x10U)
232 #define LDAP_BACK_AUTH_AUTHZ_ALL (0x20U)
233 #define LDAP_BACK_AUTH_PROXYAUTHZ_CRITICAL (0x40U)
234 #define LDAP_BACK_AUTH_DN_AUTHZID (0x100U)
235 #define LDAP_BACK_AUTH_DN_WHOAMI (0x200U)
236 #define LDAP_BACK_AUTH_DN_MASK (LDAP_BACK_AUTH_DN_AUTHZID|LDAP_BACK_AUTH_DN_WHOAMI)
237 #define li_idassert_flags li_idassert.si_flags
240 #define li_idassert_authz li_idassert.si_authz
242 BerVarray si_passthru;
243 #define li_idassert_passthru li_idassert.si_passthru
247 * Hook to allow mucking with ldapinfo_t when quarantine is over
249 typedef int (*ldap_back_quarantine_f)( struct ldapinfo_t *, void * );
251 typedef struct ldapinfo_t {
252 /* li_uri: the string that goes into ldap_initialize()
253 * TODO: use li_acl.sb_uri instead */
255 /* li_bvuri: an array of each single URI that is equivalent;
256 * to be checked for the presence of a certain item */
258 ldap_pvt_thread_mutex_t li_uri_mutex;
259 /* hack because when TLS is used we need to lock and let
260 * the li_urllist_f function to know it's locked */
261 int li_uri_mutex_do_not_lock;
263 LDAP_REBIND_PROC *li_rebind_f;
264 LDAP_URLLIST_PROC *li_urllist_f;
267 /* we only care about the TLS options here */
268 slap_bindconf li_tls;
270 slap_bindconf li_acl;
271 #define li_acl_authcID li_acl.sb_authcId
272 #define li_acl_authcDN li_acl.sb_binddn
273 #define li_acl_passwd li_acl.sb_cred
274 #define li_acl_authzID li_acl.sb_authzId
275 #define li_acl_authmethod li_acl.sb_method
276 #define li_acl_sasl_mech li_acl.sb_saslmech
277 #define li_acl_sasl_realm li_acl.sb_realm
278 #define li_acl_secprops li_acl.sb_secprops
280 /* ID assert stuff */
281 slap_idassert_t li_idassert;
282 /* end of ID assert stuff */
285 #define LDAP_BACK_RETRY_UNDEFINED (-2)
286 #define LDAP_BACK_RETRY_FOREVER (-1)
287 #define LDAP_BACK_RETRY_NEVER (0)
288 #define LDAP_BACK_RETRY_DEFAULT (3)
292 /* 0xFFF00000U are reserved for back-meta */
294 #define LDAP_BACK_F_NONE (0x00000000U)
295 #define LDAP_BACK_F_SAVECRED (0x00000001U)
296 #define LDAP_BACK_F_USE_TLS (0x00000002U)
297 #define LDAP_BACK_F_PROPAGATE_TLS (0x00000004U)
298 #define LDAP_BACK_F_TLS_CRITICAL (0x00000008U)
299 #define LDAP_BACK_F_TLS_LDAPS (0x00000010U)
301 #define LDAP_BACK_F_TLS_USE_MASK (LDAP_BACK_F_USE_TLS|LDAP_BACK_F_TLS_CRITICAL)
302 #define LDAP_BACK_F_TLS_PROPAGATE_MASK (LDAP_BACK_F_PROPAGATE_TLS|LDAP_BACK_F_TLS_CRITICAL)
303 #define LDAP_BACK_F_TLS_MASK (LDAP_BACK_F_TLS_USE_MASK|LDAP_BACK_F_TLS_PROPAGATE_MASK|LDAP_BACK_F_TLS_LDAPS)
304 #define LDAP_BACK_F_CHASE_REFERRALS (0x00000020U)
305 #define LDAP_BACK_F_PROXY_WHOAMI (0x00000040U)
307 #define LDAP_BACK_F_T_F (0x00000080U)
308 #define LDAP_BACK_F_T_F_DISCOVER (0x00000100U)
309 #define LDAP_BACK_F_T_F_MASK (LDAP_BACK_F_T_F)
310 #define LDAP_BACK_F_T_F_MASK2 (LDAP_BACK_F_T_F_MASK|LDAP_BACK_F_T_F_DISCOVER)
312 #define LDAP_BACK_F_MONITOR (0x00000200U)
313 #define LDAP_BACK_F_SINGLECONN (0x00000400U)
314 #define LDAP_BACK_F_USE_TEMPORARIES (0x00000800U)
316 #define LDAP_BACK_F_ISOPEN (0x00001000U)
318 #define LDAP_BACK_F_CANCEL_ABANDON (0x00000000U)
319 #define LDAP_BACK_F_CANCEL_IGNORE (0x00002000U)
320 #define LDAP_BACK_F_CANCEL_EXOP (0x00004000U)
321 #define LDAP_BACK_F_CANCEL_EXOP_DISCOVER (0x00008000U)
322 #define LDAP_BACK_F_CANCEL_MASK (LDAP_BACK_F_CANCEL_IGNORE|LDAP_BACK_F_CANCEL_EXOP)
323 #define LDAP_BACK_F_CANCEL_MASK2 (LDAP_BACK_F_CANCEL_MASK|LDAP_BACK_F_CANCEL_EXOP_DISCOVER)
325 #define LDAP_BACK_F_QUARANTINE (0x00010000U)
327 #ifdef SLAP_CONTROL_X_SESSION_TRACKING
328 #define LDAP_BACK_F_ST_REQUEST (0x00020000U)
329 #define LDAP_BACK_F_ST_RESPONSE (0x00040000U)
330 #endif /* SLAP_CONTROL_X_SESSION_TRACKING */
332 #define LDAP_BACK_F_NOREFS (0x00080000U)
333 #define LDAP_BACK_F_NOUNDEFFILTER (0x00100000U)
335 #define LDAP_BACK_F_ONERR_STOP (0x00200000U)
337 #define LDAP_BACK_ISSET_F(ff,f) ( ( (ff) & (f) ) == (f) )
338 #define LDAP_BACK_ISMASK_F(ff,m,f) ( ( (ff) & (m) ) == (f) )
340 #define LDAP_BACK_ISSET(li,f) LDAP_BACK_ISSET_F( (li)->li_flags, (f) )
341 #define LDAP_BACK_ISMASK(li,m,f) LDAP_BACK_ISMASK_F( (li)->li_flags, (m), (f) )
343 #define LDAP_BACK_SAVECRED(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_SAVECRED )
344 #define LDAP_BACK_USE_TLS(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_USE_TLS )
345 #define LDAP_BACK_PROPAGATE_TLS(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_PROPAGATE_TLS )
346 #define LDAP_BACK_TLS_CRITICAL(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_TLS_CRITICAL )
347 #define LDAP_BACK_CHASE_REFERRALS(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_CHASE_REFERRALS )
348 #define LDAP_BACK_PROXY_WHOAMI(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_PROXY_WHOAMI )
350 #define LDAP_BACK_USE_TLS_F(ff) LDAP_BACK_ISSET_F( (ff), LDAP_BACK_F_USE_TLS )
351 #define LDAP_BACK_PROPAGATE_TLS_F(ff) LDAP_BACK_ISSET_F( (ff), LDAP_BACK_F_PROPAGATE_TLS )
352 #define LDAP_BACK_TLS_CRITICAL_F(ff) LDAP_BACK_ISSET_F( (ff), LDAP_BACK_F_TLS_CRITICAL )
354 #define LDAP_BACK_T_F(li) LDAP_BACK_ISMASK( (li), LDAP_BACK_F_T_F_MASK, LDAP_BACK_F_T_F )
355 #define LDAP_BACK_T_F_DISCOVER(li) LDAP_BACK_ISMASK( (li), LDAP_BACK_F_T_F_MASK2, LDAP_BACK_F_T_F_DISCOVER )
357 #define LDAP_BACK_MONITOR(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_MONITOR )
358 #define LDAP_BACK_SINGLECONN(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_SINGLECONN )
359 #define LDAP_BACK_USE_TEMPORARIES(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_USE_TEMPORARIES)
361 #define LDAP_BACK_ISOPEN(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_ISOPEN )
363 #define LDAP_BACK_ABANDON(li) LDAP_BACK_ISMASK( (li), LDAP_BACK_F_CANCEL_MASK, LDAP_BACK_F_CANCEL_ABANDON )
364 #define LDAP_BACK_IGNORE(li) LDAP_BACK_ISMASK( (li), LDAP_BACK_F_CANCEL_MASK, LDAP_BACK_F_CANCEL_IGNORE )
365 #define LDAP_BACK_CANCEL(li) LDAP_BACK_ISMASK( (li), LDAP_BACK_F_CANCEL_MASK, LDAP_BACK_F_CANCEL_EXOP )
366 #define LDAP_BACK_CANCEL_DISCOVER(li) LDAP_BACK_ISMASK( (li), LDAP_BACK_F_CANCEL_MASK2, LDAP_BACK_F_CANCEL_EXOP_DISCOVER )
368 #define LDAP_BACK_QUARANTINE(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_QUARANTINE )
370 #ifdef SLAP_CONTROL_X_SESSION_TRACKING
371 #define LDAP_BACK_ST_REQUEST(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_ST_REQUEST)
372 #define LDAP_BACK_ST_RESPONSE(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_ST_RESPONSE)
373 #endif /* SLAP_CONTROL_X_SESSION_TRACKING */
375 #define LDAP_BACK_NOREFS(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_NOREFS)
376 #define LDAP_BACK_NOUNDEFFILTER(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_NOUNDEFFILTER)
378 #define LDAP_BACK_ONERR_STOP(li) LDAP_BACK_ISSET( (li), LDAP_BACK_F_ONERR_STOP)
382 unsigned long li_conn_nextid;
384 /* cached connections;
385 * special conns are in tailq rather than in tree */
386 ldap_avl_info_t li_conninfo;
389 LDAP_TAILQ_HEAD(lc_conn_priv_q, ldapconn_t) lic_priv;
390 } li_conn_priv[ LDAP_BACK_PCONN_LAST ];
391 int li_conn_priv_max;
392 #define LDAP_BACK_CONN_PRIV_MIN (1)
393 #define LDAP_BACK_CONN_PRIV_MAX (256)
394 /* must be between LDAP_BACK_CONN_PRIV_MIN
395 * and LDAP_BACK_CONN_PRIV_MAX ! */
396 #define LDAP_BACK_CONN_PRIV_DEFAULT (16)
398 ldap_monitor_info_t li_monitor_info;
400 sig_atomic_t li_isquarantined;
401 #define LDAP_BACK_FQ_NO (0)
402 #define LDAP_BACK_FQ_YES (1)
403 #define LDAP_BACK_FQ_RETRYING (2)
405 slap_retry_info_t li_quarantine;
406 ldap_pvt_thread_mutex_t li_quarantine_mutex;
407 ldap_back_quarantine_f li_quarantine_f;
408 void *li_quarantine_p;
410 time_t li_network_timeout;
412 time_t li_idle_timeout;
413 time_t li_timeout[ SLAP_OP_LAST ];
415 ldap_pvt_thread_mutex_t li_counter_mutex;
416 ldap_pvt_mp_t li_ops_completed[SLAP_OP_LAST];
419 #define LDAP_ERR_OK(err) ((err) == LDAP_SUCCESS || (err) == LDAP_COMPARE_FALSE || (err) == LDAP_COMPARE_TRUE)
421 typedef enum ldap_back_send_t {
422 LDAP_BACK_DONTSEND = 0x00,
423 LDAP_BACK_SENDOK = 0x01,
424 LDAP_BACK_SENDERR = 0x02,
425 LDAP_BACK_SENDRESULT = (LDAP_BACK_SENDOK|LDAP_BACK_SENDERR),
426 LDAP_BACK_BINDING = 0x04,
428 LDAP_BACK_BIND_DONTSEND = (LDAP_BACK_BINDING),
429 LDAP_BACK_BIND_SOK = (LDAP_BACK_BINDING|LDAP_BACK_SENDOK),
430 LDAP_BACK_BIND_SERR = (LDAP_BACK_BINDING|LDAP_BACK_SENDERR),
431 LDAP_BACK_BIND_SRES = (LDAP_BACK_BINDING|LDAP_BACK_SENDRESULT),
433 LDAP_BACK_RETRYING = 0x08,
434 LDAP_BACK_RETRY_DONTSEND = (LDAP_BACK_RETRYING),
435 LDAP_BACK_RETRY_SOK = (LDAP_BACK_RETRYING|LDAP_BACK_SENDOK),
436 LDAP_BACK_RETRY_SERR = (LDAP_BACK_RETRYING|LDAP_BACK_SENDERR),
437 LDAP_BACK_RETRY_SRES = (LDAP_BACK_RETRYING|LDAP_BACK_SENDRESULT),
439 LDAP_BACK_GETCONN = 0x10
442 /* define to use asynchronous StartTLS */
443 #define SLAP_STARTTLS_ASYNCHRONOUS
445 /* timeout to use when calling ldap_result() */
446 #define LDAP_BACK_RESULT_TIMEOUT (0)
447 #define LDAP_BACK_RESULT_UTIMEOUT (100000)
448 #define LDAP_BACK_TV_SET(tv) \
450 (tv)->tv_sec = LDAP_BACK_RESULT_TIMEOUT; \
451 (tv)->tv_usec = LDAP_BACK_RESULT_UTIMEOUT; \
454 #ifndef LDAP_BACK_PRINT_CONNTREE
455 #define LDAP_BACK_PRINT_CONNTREE 0
456 #endif /* !LDAP_BACK_PRINT_CONNTREE */
458 typedef struct ldap_extra_t {
459 int (*proxy_authz_ctrl)( Operation *op, SlapReply *rs, struct berval *bound_ndn,
460 int version, slap_idassert_t *si, LDAPControl *ctrl );
461 int (*controls_free)( Operation *op, SlapReply *rs, LDAPControl ***pctrls );
462 int (*idassert_authzfrom_parse)( struct config_args_s *ca, slap_idassert_t *si );
463 int (*idassert_passthru_parse_cf)( const char *fname, int lineno, const char *arg, slap_idassert_t *si );
464 int (*idassert_parse)( struct config_args_s *ca, slap_idassert_t *si );
465 void (*retry_info_destroy)( slap_retry_info_t *ri );
466 int (*retry_info_parse)( char *in, slap_retry_info_t *ri, char *buf, ber_len_t buflen );
467 int (*retry_info_unparse)( slap_retry_info_t *ri, struct berval *bvout );
468 int (*connid2str)( const ldapconn_base_t *lc, char *buf, ber_len_t buflen );
473 #include "proto-ldap.h"
475 #endif /* SLAPD_LDAP_H */