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 int ldap_back_freeconn( Operation *op, struct ldapconn *lc );
86 struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
87 int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
88 int ldap_back_retry(struct ldapconn *lc, Operation *op, SlapReply *rs);
89 int ldap_back_map_result(SlapReply *rs);
90 int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
91 ber_int_t msgid, int sendok);
92 int back_ldap_LTX_init_module(int argc, char *argv[]);
94 int ldap_back_dn_massage(dncookie *dc, struct berval *dn,
97 extern int ldap_back_conn_cmp( const void *c1, const void *c2);
98 extern int ldap_back_conn_dup( void *c1, void *c2 );
99 extern void ldap_back_conn_free( void *c );
101 /* attributeType/objectClass mapping */
102 int mapping_cmp (const void *, const void *);
103 int mapping_dup (void *, void *);
105 void ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping ** );
106 void ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *m,
108 #define BACKLDAP_MAP 0
109 #define BACKLDAP_REMAP 1
111 ldap_back_map_filter(
112 struct ldapmap *at_map,
113 struct ldapmap *oc_map,
120 struct ldapmap *at_map,
126 extern int ldap_back_map_config(
127 struct ldapmap *oc_map,
128 struct ldapmap *at_map,
135 ldap_back_filter_map_rewrite(
141 /* suffix massaging by means of librewrite */
142 #ifdef ENABLE_REWRITE
143 extern int suffix_massage_config( struct rewrite_info *info,
144 struct berval *pvnc, struct berval *nvnc,
145 struct berval *prnc, struct berval *nrnc);
146 #endif /* ENABLE_REWRITE */
147 extern int ldap_back_referral_result_rewrite( dncookie *dc, BerVarray a_vals );
148 extern int ldap_dnattr_rewrite( dncookie *dc, BerVarray a_vals );
149 extern int ldap_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals );
151 /* (end of) from back-ldap.h before rwm removal */
153 struct metasingleconn {
155 #define META_NOT_CANDIDATE 0
156 #define META_CANDIDATE 1
157 #define META_LAST_CONN -1
160 struct berval msc_bound_ndn;
161 struct berval msc_cred;
163 #define META_UNBOUND 0
165 #define META_ANONYMOUS 2
168 #define META_LAST(lsc) ((lsc)->msc_candidate == META_LAST_CONN)
171 struct slap_conn *mc_conn;
172 struct rewrite_info *mc_rwinfo;
175 * means that the connection is bound;
176 * of course only one target actually is ...
179 #define META_BOUND_NONE -1
180 #define META_BOUND_ALL -2
181 /* supersedes the connection stuff */
182 struct metasingleconn *mc_conns;
187 struct berval mt_psuffix; /* pretty suffix */
188 struct berval mt_nsuffix; /* normalized suffix */
189 struct berval mt_binddn;
190 struct berval mt_bindpw;
192 struct berval mt_pseudorootdn;
193 struct berval mt_pseudorootpw;
195 struct ldaprwmap mt_rwmap;
199 ldap_pvt_thread_mutex_t mutex;
202 #define META_DNCACHE_DISABLED 0
203 #define META_DNCACHE_FOREVER -1
204 long int ttl; /* seconds; 0: no cache, -1: no expiry */
211 #define META_DEFAULT_TARGET_NONE -1
212 struct metatarget **targets;
214 struct rewrite_info *rwinfo;
217 struct metadncache cache;
219 ldap_pvt_thread_mutex_t conn_mutex;
225 #define META_OP_ALLOW_MULTIPLE 0x00
226 #define META_OP_REQUIRE_SINGLE 0x01
227 #define META_OP_REQUIRE_ALL 0x02
228 extern struct metaconn *
257 back_meta_LTX_init_module(
278 meta_back_is_candidate(
279 struct berval *nsuffix,
284 meta_back_count_candidates(
290 meta_back_is_candidate_unique(
296 meta_back_select_unique_candidate(
302 meta_clear_unused_candidates(
310 meta_clear_one_candidate(
311 struct metasingleconn *lc,
316 * Dn cache stuff (experimental)
330 #define META_TARGET_NONE (-1)
332 meta_dncache_get_target(
333 struct metadncache *cache,
338 meta_dncache_update_entry(
339 struct metadncache *cache,
345 meta_dncache_delete_entry(
346 struct metadncache *cache,
357 #endif /* SLAPD_META_H */