]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/back-ldap.h
Sync with HEAD
[openldap] / servers / slapd / back-ldap / back-ldap.h
1 /* back-ldap.h - ldap backend header file */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1999-2003 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16 /* ACKNOWLEDGEMENTS:
17  * This work was initially developed by the Howard Chu for inclusion
18  * in OpenLDAP Software and subsequently enhanced by Pierangelo
19  * Masarati.
20  */
21 /* This is an altered version */
22 /*
23  * Copyright 1999, Howard Chu, All rights reserved. <hyc@highlandsun.com>
24  * 
25  * Permission is granted to anyone to use this software for any purpose
26  * on any computer system, and to alter it and redistribute it, subject
27  * to the following restrictions:
28  * 
29  * 1. The author is not responsible for the consequences of use of this
30  *    software, no matter how awful, even if they arise from flaws in it.
31  * 
32  * 2. The origin of this software must not be misrepresented, either by
33  *    explicit claim or by omission.  Since few users ever read sources,
34  *    credits should appear in the documentation.
35  * 
36  * 3. Altered versions must be plainly marked as such, and must not be
37  *    misrepresented as being the original software.  Since few users
38  *    ever read sources, credits should appear in the documentation.
39  * 
40  * 4. This notice may not be removed or altered.
41  *
42  *
43  *
44  * Copyright 2000, Pierangelo Masarati, All rights reserved. <ando@sys-net.it>
45  * 
46  * This software is being modified by Pierangelo Masarati.
47  * The previously reported conditions apply to the modified code as well.
48  * Changes in the original code are highlighted where required.
49  * Credits for the original code go to the author, Howard Chu.      
50  */
51
52 #ifndef SLAPD_LDAP_H
53 #define SLAPD_LDAP_H
54
55 #include "external.h"
56
57 /* String rewrite library */
58 #ifdef ENABLE_REWRITE
59 #include "rewrite.h"
60 #endif /* ENABLE_REWRITE */
61
62 LDAP_BEGIN_DECL
63
64 struct slap_conn;
65 struct slap_op;
66 struct slap_backend_db;
67
68 struct ldapconn {
69         struct slap_conn        *conn;
70         LDAP            *ld;
71         struct berval   cred;
72         struct berval   bound_dn;
73         struct berval   local_dn;
74         int             bound;
75         ldap_pvt_thread_mutex_t         lc_mutex;
76 };
77
78 struct ldapmap {
79         int drop_missing;
80
81         Avlnode *map;
82         Avlnode *remap;
83 };
84
85 struct ldapmapping {
86         struct berval src;
87         struct berval dst;
88 };
89
90 struct ldaprwmap {
91         /*
92          * DN rewriting
93          */
94 #ifdef ENABLE_REWRITE
95         struct rewrite_info *rwm_rw;
96 #else /* !ENABLE_REWRITE */
97         /* some time the suffix massaging without librewrite
98          * will be disabled */
99         BerVarray rwm_suffix_massage;
100 #endif /* !ENABLE_REWRITE */
101
102         /*
103          * Attribute/objectClass mapping
104          */
105         struct ldapmap rwm_oc;
106         struct ldapmap rwm_at;
107 };
108
109 struct ldapinfo {
110         struct slap_backend_db  *be;
111         char *url;
112         struct berval binddn;
113         struct berval bindpw;
114         ldap_pvt_thread_mutex_t         conn_mutex;
115         int savecred;
116         Avlnode *conntree;
117
118 #if 0
119 #ifdef ENABLE_REWRITE
120         struct rewrite_info *rwinfo;
121 #else /* !ENABLE_REWRITE */
122         BerVarray suffix_massage;
123 #endif /* !ENABLE_REWRITE */
124
125         struct ldapmap oc_map;
126         struct ldapmap at_map;
127 #endif
128
129         struct ldaprwmap rwmap;
130 };
131
132 /* Whatever context ldap_back_dn_massage needs... */
133 typedef struct dncookie {
134         struct ldaprwmap *rwmap;
135
136 #ifdef ENABLE_REWRITE
137         Connection *conn;
138         char *ctx;
139         SlapReply *rs;
140 #else
141         int normalized;
142         int tofrom;
143 #endif
144 } dncookie;
145
146 struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
147 int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
148 int ldap_back_map_result(SlapReply *rs);
149 int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
150         ber_int_t msgid, int sendok);
151 int     back_ldap_LTX_init_module(int argc, char *argv[]);
152
153 int ldap_back_dn_massage(dncookie *dc, struct berval *dn,
154         struct berval *res);
155
156 extern int ldap_back_conn_cmp( const void *c1, const void *c2);
157 extern int ldap_back_conn_dup( void *c1, void *c2 );
158 extern void ldap_back_conn_free( void *c );
159
160 /* attributeType/objectClass mapping */
161 int mapping_cmp (const void *, const void *);
162 int mapping_dup (void *, void *);
163
164 void ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping ** );
165 void ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *m,
166         int remap );
167 #define BACKLDAP_MAP    0
168 #define BACKLDAP_REMAP  1
169 char *
170 ldap_back_map_filter(
171                 struct ldapmap *at_map,
172                 struct ldapmap *oc_map,
173                 struct berval *f,
174                 int remap
175 );
176
177 int
178 ldap_back_map_attrs(
179                 struct ldapmap *at_map,
180                 AttributeName *a,
181                 int remap,
182                 char ***mapped_attrs
183 );
184
185 extern void mapping_free ( void *mapping );
186
187 extern int ldap_back_map_config(
188                 struct ldapmap  *oc_map,
189                 struct ldapmap  *at_map,
190                 const char      *fname,
191                 int             lineno,
192                 int             argc,
193                 char            **argv );
194
195 extern int
196 ldap_back_filter_map_rewrite(
197                 dncookie                *dc,
198                 Filter                  *f,
199                 struct berval           *fstr,
200                 int                     remap );
201
202 /* suffix massaging by means of librewrite */
203 #ifdef ENABLE_REWRITE
204 extern int suffix_massage_config( struct rewrite_info *info,
205                 struct berval *pvnc, struct berval *nvnc,
206                 struct berval *prnc, struct berval *nrnc);
207 #endif /* ENABLE_REWRITE */
208 extern int ldap_dnattr_rewrite( dncookie *dc, BerVarray a_vals );
209 extern int ldap_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals );
210
211 extern int ldap_chain_setup();
212
213 LDAP_END_DECL
214
215 #endif /* SLAPD_LDAP_H */