]> git.sur5r.net Git - openldap/blob - servers/slapd/back-meta/back-meta.h
Changed search attrs to struct berval **.
[openldap] / servers / slapd / back-meta / back-meta.h
1 /*
2  * Copyright 1998-2001 The OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  *
5  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
6  *
7  * Copyright 2001, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
8  *
9  * This work has been developed to fulfill the requirements
10  * of SysNet s.n.c. <http:www.sys-net.it> and it has been donated
11  * to the OpenLDAP Foundation in the hope that it may be useful
12  * to the Open Source community, but WITHOUT ANY WARRANTY.
13  *
14  * Permission is granted to anyone to use this software for any purpose
15  * on any computer system, and to alter it and redistribute it, subject
16  * to the following restrictions:
17  *
18  * 1. The author and SysNet s.n.c. are not responsible for the consequences
19  *    of use of this software, no matter how awful, even if they arise from 
20  *    flaws in it.
21  *
22  * 2. The origin of this software must not be misrepresented, either by
23  *    explicit claim or by omission.  Since few users ever read sources,
24  *    credits should appear in the documentation.
25  *
26  * 3. Altered versions must be plainly marked as such, and must not be
27  *    misrepresented as being the original software.  Since few users
28  *    ever read sources, credits should appear in the documentation.
29  *    SysNet s.n.c. cannot be responsible for the consequences of the
30  *    alterations.
31  *                         
32  * 4. This notice may not be removed or altered.
33  *
34  *
35  * This software is based on the backend back-ldap, implemented
36  * by Howard Chu <hyc@highlandsun.com>, and modified by Mark Valence
37  * <kurash@sassafras.com>, Pierangelo Masarati <ando@sys-net.it> and other
38  * contributors. The contribution of the original software to the present
39  * implementation is acknowledged in this copyright statement.
40  *
41  * A special acknowledgement goes to Howard for the overall architecture
42  * (and for borrowing large pieces of code), and to Mark, who implemented
43  * from scratch the attribute/objectclass mapping.
44  *
45  * The original copyright statement follows.
46  *
47  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
48  *
49  * Permission is granted to anyone to use this software for any purpose
50  * on any computer system, and to alter it and redistribute it, subject
51  * to the following restrictions:
52  *
53  * 1. The author is not responsible for the consequences of use of this
54  *    software, no matter how awful, even if they arise from flaws in it.
55  *
56  * 2. The origin of this software must not be misrepresented, either by
57  *    explicit claim or by omission.  Since few users ever read sources,
58  *    credits should appear in the documentation.
59  *
60  * 3. Altered versions must be plainly marked as such, and must not be
61  *    misrepresented as being the original software.  Since few users
62  *    ever read sources, credits should appear in the
63  *    documentation.
64  *
65  * 4. This notice may not be removed or altered.
66  *                
67  */ 
68
69 #ifndef SLAPD_LDAP_H
70 #error "include servers/slapd/back-ldap/back-ldap.h before this file!"
71 #endif /* SLAPD_LDAP_H */
72
73 #ifndef SLAPD_META_H
74 #define SLAPD_META_H
75
76 #include "external.h"
77
78 /* String rewrite library */
79 #include "rewrite.h"
80
81 LDAP_BEGIN_DECL
82
83 struct slap_conn;
84 struct slap_op;
85
86 struct metasingleconn {
87         int                     candidate;
88 #define META_NOT_CANDIDATE      0
89 #define META_CANDIDATE          1
90         
91         LDAP                    *ld;
92         char                    *bound_dn;
93         int                     bound;
94 #define META_UNBOUND            0
95 #define META_BOUND              1
96 #define META_ANONYMOUS          2
97 };
98
99 struct metaconn {
100         struct slap_conn        *conn;
101         struct rewrite_info     *rwinfo;
102         
103         /*
104          * means that the connection is bound; 
105          * of course only one target actually is ...
106          */
107         int             bound_target;
108 #define META_BOUND_NONE         -1
109 #define META_BOUND_ALL          -2
110         /* supersedes the connection stuff */
111         struct metasingleconn **conns;
112 };
113
114 struct metatarget {
115         char                    *uri;
116         char                    *suffix;/* normalized suffix */
117         char                    *binddn;
118         char                    *bindpw;
119
120         char                    *pseudorootdn;
121         char                    *pseudorootpw;
122
123         struct rewrite_info     *rwinfo;
124
125         struct ldapmap          oc_map;
126         struct ldapmap          at_map;
127 };
128
129 struct metadncache {
130         ldap_pvt_thread_mutex_t mutex;
131         Avlnode                 *tree;
132
133 #define META_DNCACHE_DISABLED   0
134 #define META_DNCACHE_FOREVER    -1
135         long int                ttl;  /* seconds; 0: no cache, -1: no expiry */
136 };
137
138 struct metainfo {
139         int                     ntargets;
140         int                     defaulttarget;
141 #define META_DEFAULT_TARGET_NONE        -1
142         struct metatarget       **targets;
143
144         struct metadncache      cache;
145         
146         ldap_pvt_thread_mutex_t conn_mutex;
147         Avlnode                 *conntree;
148 };
149
150 extern int
151 meta_back_do_single_bind(
152                 struct metainfo         *li,
153                 struct metaconn         *lc,
154                 const char              *dn,
155                 const char              *ndn,
156                 const char              *cred,
157                 int                     method,
158                 int                     candidate
159 );
160
161
162 #define META_OP_ALLOW_MULTIPLE          0x00
163 #define META_OP_REQUIRE_SINGLE          0x01
164 #define META_OP_REQUIRE_ALL             0x02
165 extern struct metaconn *
166 meta_back_getconn(
167                 struct                  metainfo *li,
168                 struct                  slap_conn *conn,
169                 struct                  slap_op *op,
170                 int                     op_type,
171                 const                   char *dn,
172                 int                     *candidate
173 );
174
175 extern int
176 meta_back_dobind(
177                 struct metaconn         *lc,
178                 Operation               *op
179 );
180
181 extern int
182 meta_back_op_result(
183                 struct metaconn         *lc,
184                 Operation               *op
185 );
186
187 extern int
188 back_meta_LTX_init_module(
189                 int                     argc,
190                 char                    *argv[]
191 );
192
193 extern int
194 meta_back_conn_cmp(
195                 const void              *c1,
196                 const void              *c2
197 );
198
199 extern int
200 meta_back_conn_dup(
201                 void                    *c1,
202                 void                    *c2
203 );
204
205 /*
206  * Candidate stuff
207  */
208 extern int
209 meta_back_is_candidate(
210                 const char              *nsuffix,
211                 const char              *ndn,
212                 int                     ndnlen
213 );
214
215 extern int
216 meta_back_count_candidates(
217                 struct metainfo         *li,
218                 const char              *ndn
219 );
220
221 extern int
222 meta_back_is_candidate_unique(
223                 struct metainfo         *li,
224                 const char              *ndn
225 );
226
227 extern int
228 meta_back_select_unique_candidate(
229                 struct metainfo         *li,
230                 const char              *ndn
231 );
232
233 extern int
234 meta_clear_unused_candidates(
235                 struct metainfo         *li,
236                 struct metaconn         *lc,
237                 int                     candidate,
238                 int                     reallyclean
239 );
240
241 extern int
242 meta_clear_one_candidate(
243                 struct metasingleconn   *lc,
244                 int                     reallyclean
245 );
246
247 /*
248  * Dn cache stuff (experimental)
249  */
250 extern int
251 meta_dncache_cmp(
252                 const void              *c1,
253                 const void              *c2
254 );
255
256 extern int
257 meta_dncache_dup(
258                 void                    *c1,
259                 void                    *c2
260 );
261
262 extern int
263 meta_dncache_get_target(
264                 struct metadncache      *cache,
265                 const char              *ndn
266 );
267
268 extern int
269 meta_dncache_update_entry(
270                 struct metadncache      *cache,
271                 const char              *ndn,
272                 int                     target
273 );
274
275 extern int
276 meta_dncache_delete_entry(
277                 struct metadncache      *cache,
278                 const char              *ndn
279 );
280
281 extern void
282 meta_dncache_free(
283                 void *entry
284 );
285
286 LDAP_END_DECL
287
288 #endif /* SLAPD_META_H */
289