]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldap/back-ldap.h
Use AC_STRERROR_R
[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-2004 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         LDAPURLDesc     *lud;
85         struct berval binddn;
86         struct berval bindpw;
87 #ifdef LDAP_BACK_PROXY_AUTHZ
88         struct berval proxyauthzdn;
89         struct berval proxyauthzpw;
90 #endif /* LDAP_BACK_PROXY_AUTHZ */
91         ldap_pvt_thread_mutex_t         conn_mutex;
92         int savecred;
93         Avlnode *conntree;
94
95 #if 0
96 #ifdef ENABLE_REWRITE
97         struct rewrite_info *rwinfo;
98 #else /* !ENABLE_REWRITE */
99         BerVarray suffix_massage;
100 #endif /* !ENABLE_REWRITE */
101
102         struct ldapmap oc_map;
103         struct ldapmap at_map;
104 #endif
105
106         struct ldaprwmap rwmap;
107 };
108
109 /* Whatever context ldap_back_dn_massage needs... */
110 typedef struct dncookie {
111         struct ldaprwmap *rwmap;
112
113 #ifdef ENABLE_REWRITE
114         Connection *conn;
115         char *ctx;
116         SlapReply *rs;
117 #else
118         int normalized;
119         int tofrom;
120 #endif
121 } dncookie;
122
123 struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
124 int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
125 int ldap_back_map_result(SlapReply *rs);
126 int ldap_back_op_result(struct ldapconn *lc, Operation *op, SlapReply *rs,
127         ber_int_t msgid, int sendok);
128 int     back_ldap_LTX_init_module(int argc, char *argv[]);
129
130 int ldap_back_dn_massage(dncookie *dc, struct berval *dn,
131         struct berval *res);
132
133 extern int ldap_back_conn_cmp( const void *c1, const void *c2);
134 extern int ldap_back_conn_dup( void *c1, void *c2 );
135 extern void ldap_back_conn_free( void *c );
136
137 /* attributeType/objectClass mapping */
138 int mapping_cmp (const void *, const void *);
139 int mapping_dup (void *, void *);
140
141 void ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping ** );
142 void ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *m,
143         int remap );
144 #define BACKLDAP_MAP    0
145 #define BACKLDAP_REMAP  1
146 char *
147 ldap_back_map_filter(
148                 struct ldapmap *at_map,
149                 struct ldapmap *oc_map,
150                 struct berval *f,
151                 int remap
152 );
153
154 int
155 ldap_back_map_attrs(
156                 struct ldapmap *at_map,
157                 AttributeName *a,
158                 int remap,
159                 char ***mapped_attrs
160 );
161
162 extern void mapping_free ( void *mapping );
163
164 extern int ldap_back_map_config(
165                 struct ldapmap  *oc_map,
166                 struct ldapmap  *at_map,
167                 const char      *fname,
168                 int             lineno,
169                 int             argc,
170                 char            **argv );
171
172 extern int
173 ldap_back_filter_map_rewrite(
174                 dncookie                *dc,
175                 Filter                  *f,
176                 struct berval           *fstr,
177                 int                     remap );
178
179 /* suffix massaging by means of librewrite */
180 #ifdef ENABLE_REWRITE
181 extern int suffix_massage_config( struct rewrite_info *info,
182                 struct berval *pvnc, struct berval *nvnc,
183                 struct berval *prnc, struct berval *nrnc);
184 #endif /* ENABLE_REWRITE */
185 extern int ldap_dnattr_rewrite( dncookie *dc, BerVarray a_vals );
186 extern int ldap_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals );
187
188 #ifdef LDAP_BACK_PROXY_AUTHZ
189 extern int
190 ldap_back_proxy_authz_ctrl(
191                 struct ldapconn *lc,
192                 Operation       *op,
193                 SlapReply       *rs,
194                 LDAPControl     ***pctrls );
195 #endif /* LDAP_BACK_PROXY_AUTHZ */
196
197 LDAP_END_DECL
198
199 #endif /* SLAPD_LDAP_H */