]> git.sur5r.net Git - openldap/blob - servers/slapd/overlays/rwm.h
9c17b198e9a06dc3a70ba1fc706c82f4237b19c4
[openldap] / servers / slapd / overlays / rwm.h
1 /* rwm.h - dn rewrite/attribute mapping 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 1999-2003 Howard Chu.
7  * Portions Copyright 2000-2003 Pierangelo Masarati.
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 RWM_H
25 #define RWM_H
26
27 /* String rewrite library */
28 #ifdef ENABLE_REWRITE
29 #include "rewrite.h"
30 #endif /* ENABLE_REWRITE */
31
32 LDAP_BEGIN_DECL
33
34 struct ldapmap {
35         int drop_missing;
36
37         Avlnode *map;
38         Avlnode *remap;
39 };
40
41 struct ldapmapping {
42         struct berval src;
43         struct berval dst;
44 };
45
46 struct ldaprwmap {
47         /*
48          * DN rewriting
49          */
50 #ifdef ENABLE_REWRITE
51         struct rewrite_info *rwm_rw;
52 #else /* !ENABLE_REWRITE */
53         /* some time the suffix massaging without librewrite
54          * will be disabled */
55         BerVarray rwm_suffix_massage;
56 #endif /* !ENABLE_REWRITE */
57
58         /*
59          * Attribute/objectClass mapping
60          */
61         struct ldapmap rwm_oc;
62         struct ldapmap rwm_at;
63 };
64
65 /* Whatever context ldap_back_dn_massage needs... */
66 typedef struct dncookie {
67         struct ldaprwmap *rwmap;
68
69 #ifdef ENABLE_REWRITE
70         Connection *conn;
71         char *ctx;
72         SlapReply *rs;
73 #else
74         int normalized;
75         int tofrom;
76 #endif
77 } dncookie;
78
79 int rwm_dn_massage(dncookie *dc, struct berval *dn, struct berval *res);
80
81 /* attributeType/objectClass mapping */
82 int mapping_cmp (const void *, const void *);
83 int mapping_dup (void *, void *);
84
85 void rwm_map_init ( struct ldapmap *lm, struct ldapmapping ** );
86 void rwm_map ( struct ldapmap *map, struct berval *s, struct berval *m,
87         int remap );
88 #define BACKLDAP_MAP    0
89 #define BACKLDAP_REMAP  1
90 char *
91 rwm_map_filter(
92                 struct ldapmap *at_map,
93                 struct ldapmap *oc_map,
94                 struct berval *f,
95                 int remap
96 );
97
98 int
99 rwm_map_attrs(
100                 struct ldapmap *at_map,
101                 AttributeName *a,
102                 int remap,
103                 char ***mapped_attrs
104 );
105
106 extern void mapping_free ( void *mapping );
107
108 extern int rwm_map_config(
109                 struct ldapmap  *oc_map,
110                 struct ldapmap  *at_map,
111                 const char      *fname,
112                 int             lineno,
113                 int             argc,
114                 char            **argv );
115
116 extern int
117 rwm_filter_map_rewrite(
118                 dncookie                *dc,
119                 Filter                  *f,
120                 struct berval           *fstr,
121                 int                     remap );
122
123 /* suffix massaging by means of librewrite */
124 #ifdef ENABLE_REWRITE
125 extern int suffix_massage_config( struct rewrite_info *info,
126                 struct berval *pvnc, struct berval *nvnc,
127                 struct berval *prnc, struct berval *nrnc);
128 #endif /* ENABLE_REWRITE */
129 extern int ldap_dnattr_rewrite( dncookie *dc, BerVarray a_vals );
130 extern int ldap_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals );
131
132 LDAP_END_DECL
133
134 #endif /* RWM_H */