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