]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/back-ldap.h
c29555905cf0670400b3f36f9ad49490a994823a
[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  * Portions Copyright 2000-2003 Pierangelo Masarati.
7  * Portions Copyright 1999-2003 Howard Chu.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted only as authorized by the OpenLDAP
12  * Public License.
13  *
14  * A copy of this license is available in the file LICENSE in the
15  * top-level directory of the distribution or, alternatively, at
16  * <http://www.OpenLDAP.org/license.html>.
17  */
18 /* ACKNOWLEDGEMENTS:
19  * This work was initially developed by the Howard Chu for inclusion
20  * in OpenLDAP Software and subsequently enhanced by Pierangelo
21  * Masarati.
22  */
23
24 #ifndef SLAPD_LDAP_H
25 #define SLAPD_LDAP_H
26
27 #include "external.h"
28
29 /* String rewrite library */
30 #ifdef ENABLE_REWRITE
31 #include "rewrite.h"
32 #endif /* ENABLE_REWRITE */
33
34 LDAP_BEGIN_DECL
35
36 struct slap_conn;
37 struct slap_op;
38 struct slap_backend_db;
39
40 struct ldapconn {
41         struct slap_conn        *conn;
42         LDAP            *ld;
43         struct berval   cred;
44         struct berval   bound_dn;
45         struct berval   local_dn;
46         int             bound;
47         ldap_pvt_thread_mutex_t         lc_mutex;
48 };
49
50 struct ldapmap {
51         int drop_missing;
52
53         Avlnode *map;
54         Avlnode *remap;
55 };
56
57 struct ldapmapping {
58         struct berval src;
59         struct berval dst;
60 };
61
62 struct ldaprwmap {
63         /*
64          * DN rewriting
65          */
66 #ifdef ENABLE_REWRITE
67         struct rewrite_info *rwm_rw;
68 #else /* !ENABLE_REWRITE */
69         /* some time the suffix massaging without librewrite
70          * will be disabled */
71         BerVarray rwm_suffix_massage;
72 #endif /* !ENABLE_REWRITE */
73
74         /*
75          * Attribute/objectClass mapping
76          */
77         struct ldapmap rwm_oc;
78         struct ldapmap rwm_at;
79 };
80
81 struct ldapinfo {
82         struct slap_backend_db  *be;
83         char *url;
84         struct berval binddn;
85         struct berval bindpw;
86         ldap_pvt_thread_mutex_t         conn_mutex;
87         int savecred;
88         Avlnode *conntree;
89
90 #if 0
91 #ifdef ENABLE_REWRITE
92         struct rewrite_info *rwinfo;
93 #else /* !ENABLE_REWRITE */
94         BerVarray suffix_massage;
95 #endif /* !ENABLE_REWRITE */
96
97         struct ldapmap oc_map;
98         struct ldapmap at_map;
99 #endif
100
101         struct ldaprwmap rwmap;
102 };
103
104 /* Whatever context ldap_back_dn_massage needs... */
105 typedef struct dncookie {
106         struct ldaprwmap *rwmap;
107
108 #ifdef ENABLE_REWRITE
109         Connection *conn;
110         char *ctx;
111         SlapReply *rs;
112 #else
113         int normalized;
114         int tofrom;
115 #endif
116 } dncookie;
117
118 struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
119 int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
120 int ldap_back_map_result(SlapReply *rs);
121 int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
122         ber_int_t msgid, int sendok);
123 int     back_ldap_LTX_init_module(int argc, char *argv[]);
124
125 int ldap_back_dn_massage(dncookie *dc, struct berval *dn,
126         struct berval *res);
127
128 extern int ldap_back_conn_cmp( const void *c1, const void *c2);
129 extern int ldap_back_conn_dup( void *c1, void *c2 );
130 extern void ldap_back_conn_free( void *c );
131
132 /* attributeType/objectClass mapping */
133 int mapping_cmp (const void *, const void *);
134 int mapping_dup (void *, void *);
135
136 void ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping ** );
137 void ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *m,
138         int remap );
139 #define BACKLDAP_MAP    0
140 #define BACKLDAP_REMAP  1
141 char *
142 ldap_back_map_filter(
143                 struct ldapmap *at_map,
144                 struct ldapmap *oc_map,
145                 struct berval *f,
146                 int remap
147 );
148
149 int
150 ldap_back_map_attrs(
151                 struct ldapmap *at_map,
152                 AttributeName *a,
153                 int remap,
154                 char ***mapped_attrs
155 );
156
157 extern void mapping_free ( void *mapping );
158
159 extern int ldap_back_map_config(
160                 struct ldapmap  *oc_map,
161                 struct ldapmap  *at_map,
162                 const char      *fname,
163                 int             lineno,
164                 int             argc,
165                 char            **argv );
166
167 extern int
168 ldap_back_filter_map_rewrite(
169                 dncookie                *dc,
170                 Filter                  *f,
171                 struct berval           *fstr,
172                 int                     remap );
173
174 /* suffix massaging by means of librewrite */
175 #ifdef ENABLE_REWRITE
176 extern int suffix_massage_config( struct rewrite_info *info,
177                 struct berval *pvnc, struct berval *nvnc,
178                 struct berval *prnc, struct berval *nrnc);
179 #endif /* ENABLE_REWRITE */
180 extern int ldap_dnattr_rewrite( dncookie *dc, BerVarray a_vals );
181 extern int ldap_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals );
182
183 extern int ldap_chain_setup();
184
185 #ifdef LDAP_BACK_PROXY_AUTHZ
186 extern int
187 ldap_back_proxy_authz_ctrl(
188                 struct ldapconn *lc,
189                 Operation       *op,
190                 SlapReply       *rs,
191                 LDAPControl     ***pctrls );
192 #endif /* LDAP_BACK_PROXY_AUTHZ */
193
194 LDAP_END_DECL
195
196 #endif /* SLAPD_LDAP_H */