2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1999-2005 The OpenLDAP Foundation.
5 * Portions Copyright 2001-2003 Pierangelo Masarati.
6 * Portions Copyright 1999-2003 Howard Chu.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in the file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by the Howard Chu for inclusion
19 * in OpenLDAP Software and subsequently enhanced by Pierangelo
24 #error "include servers/slapd/back-ldap/back-ldap.h before this file!"
25 #endif /* SLAPD_LDAP_H */
30 #include "proto-meta.h"
32 /* String rewrite library */
39 /* from back-ldap.h before rwm removal */
57 struct rewrite_info *rwm_rw;
58 #else /* !ENABLE_REWRITE */
59 /* some time the suffix massaging without librewrite
61 BerVarray rwm_suffix_massage;
62 #endif /* !ENABLE_REWRITE */
65 * Attribute/objectClass mapping
67 struct ldapmap rwm_oc;
68 struct ldapmap rwm_at;
71 /* Whatever context ldap_back_dn_massage needs... */
72 typedef struct dncookie {
73 struct ldaprwmap *rwmap;
85 #define META_BIND_NRETRIES 3
86 #define META_BIND_TIMEOUT 1000
88 int ldap_back_freeconn( Operation *op, struct ldapconn *lc );
89 struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
90 int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
91 int ldap_back_retry(struct ldapconn *lc, Operation *op, SlapReply *rs);
92 int ldap_back_map_result(SlapReply *rs);
93 int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
94 ber_int_t msgid, int sendok);
95 int back_ldap_LTX_init_module(int argc, char *argv[]);
97 int ldap_back_dn_massage(dncookie *dc, struct berval *dn,
100 extern int ldap_back_conn_cmp( const void *c1, const void *c2);
101 extern int ldap_back_conn_dup( void *c1, void *c2 );
102 extern void ldap_back_conn_free( void *c );
104 /* attributeType/objectClass mapping */
105 int mapping_cmp (const void *, const void *);
106 int mapping_dup (void *, void *);
108 void ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping ** );
109 int ldap_back_mapping ( struct ldapmap *map, struct berval *s,
110 struct ldapmapping **m, int remap );
111 void ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *m,
113 #define BACKLDAP_MAP 0
114 #define BACKLDAP_REMAP 1
116 ldap_back_map_filter(
117 struct ldapmap *at_map,
118 struct ldapmap *oc_map,
125 struct ldapmap *at_map,
131 extern int ldap_back_map_config(
132 struct ldapmap *oc_map,
133 struct ldapmap *at_map,
140 ldap_back_filter_map_rewrite(
146 /* suffix massaging by means of librewrite */
147 #ifdef ENABLE_REWRITE
148 extern int suffix_massage_config( struct rewrite_info *info,
149 struct berval *pvnc, struct berval *nvnc,
150 struct berval *prnc, struct berval *nrnc);
151 #endif /* ENABLE_REWRITE */
152 extern int ldap_back_referral_result_rewrite( dncookie *dc, BerVarray a_vals );
153 extern int ldap_dnattr_rewrite( dncookie *dc, BerVarray a_vals );
154 extern int ldap_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals );
156 /* (end of) from back-ldap.h before rwm removal */
158 struct metasingleconn {
160 #define META_NOT_CANDIDATE 0
161 #define META_CANDIDATE 1
162 #define META_LAST_CONN -1
165 struct berval msc_bound_ndn;
166 struct berval msc_cred;
168 #define META_UNBOUND 0
170 #define META_ANONYMOUS 2
173 #define META_LAST(lsc) ((lsc)->msc_candidate == META_LAST_CONN)
176 struct slap_conn *mc_conn;
177 struct rewrite_info *mc_rwinfo;
180 * means that the connection is bound;
181 * of course only one target actually is ...
184 #define META_BOUND_NONE -1
185 #define META_BOUND_ALL -2
186 /* supersedes the connection stuff */
187 struct metasingleconn *mc_conns;
192 struct berval mt_psuffix; /* pretty suffix */
193 struct berval mt_nsuffix; /* normalized suffix */
194 struct berval mt_binddn;
195 struct berval mt_bindpw;
197 struct berval mt_pseudorootdn;
198 struct berval mt_pseudorootpw;
200 struct ldaprwmap mt_rwmap;
204 ldap_pvt_thread_mutex_t mutex;
207 #define META_DNCACHE_DISABLED 0
208 #define META_DNCACHE_FOREVER -1
209 long int ttl; /* seconds; 0: no cache, -1: no expiry */
216 #define META_DEFAULT_TARGET_NONE -1
217 struct metatarget **targets;
219 struct rewrite_info *rwinfo;
222 struct metadncache cache;
224 ldap_pvt_thread_mutex_t conn_mutex;
230 #define META_OP_ALLOW_MULTIPLE 0x00
231 #define META_OP_REQUIRE_SINGLE 0x01
232 #define META_OP_REQUIRE_ALL 0x02
233 extern struct metaconn *
262 back_meta_LTX_init_module(
283 meta_back_is_candidate(
284 struct berval *nsuffix,
289 meta_back_count_candidates(
295 meta_back_is_candidate_unique(
301 meta_back_select_unique_candidate(
307 meta_clear_unused_candidates(
315 meta_clear_one_candidate(
316 struct metasingleconn *lc,
321 * Dn cache stuff (experimental)
335 #define META_TARGET_NONE (-1)
337 meta_dncache_get_target(
338 struct metadncache *cache,
343 meta_dncache_update_entry(
344 struct metadncache *cache,
350 meta_dncache_delete_entry(
351 struct metadncache *cache,
362 #endif /* SLAPD_META_H */