]> git.sur5r.net Git - openldap/blob - servers/slapd/overlays/rwm.h
added config option "normalize-mapped-attrs" to enable normalization of
[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-2007 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 /* define to enable referral DN massage by default */
35 #undef RWM_REFERRAL_REWRITE
36
37 struct ldapmap {
38         int drop_missing;
39
40         Avlnode *map;
41         Avlnode *remap;
42 };
43
44 struct ldapmapping {
45         int                     m_flags;
46 #define RWMMAP_F_NONE           0x00
47 #define RWMMAP_F_IS_OC          0x01
48 #define RWMMAP_F_FREE_SRC       0x10
49 #define RWMMAP_F_FREE_DST       0x20
50         struct berval           m_src;
51         union {
52                 AttributeDescription    *m_s_ad;
53                 ObjectClass             *m_s_oc;
54         } m_src_ref;
55 #define m_src_ad        m_src_ref.m_s_ad
56 #define m_src_oc        m_src_ref.m_s_oc
57         struct berval           m_dst;
58         union {
59                 AttributeDescription    *m_d_ad;
60                 ObjectClass             *m_d_oc;
61         } m_dst_ref;
62 #define m_dst_ad        m_dst_ref.m_d_ad
63 #define m_dst_oc        m_dst_ref.m_d_oc
64 };
65
66 struct ldaprwmap {
67         /*
68          * DN rewriting
69          */
70 #ifdef ENABLE_REWRITE
71         struct rewrite_info *rwm_rw;
72 #else /* !ENABLE_REWRITE */
73         /* some time the suffix massaging without librewrite
74          * will be disabled */
75         BerVarray rwm_suffix_massage;
76 #endif /* !ENABLE_REWRITE */
77
78         /*
79          * Attribute/objectClass mapping
80          */
81         struct ldapmap rwm_oc;
82         struct ldapmap rwm_at;
83
84 #define RWM_F_NONE                      0x0000U
85 #define RWM_F_NORMALIZE_MAPPED_ATTRS    0x0001U
86 #define RWM_F_SUPPORT_T_F               0x4000U
87 #define RWM_F_SUPPORT_T_F_DISCOVER      0x8000U
88         unsigned        rwm_flags;
89 };
90
91 /* Whatever context ldap_back_dn_massage needs... */
92 typedef struct dncookie {
93         struct ldaprwmap *rwmap;
94
95 #ifdef ENABLE_REWRITE
96         Connection *conn;
97         char *ctx;
98         SlapReply *rs;
99 #else /* !ENABLE_REWRITE */
100         int normalized;
101         int tofrom;
102 #endif /* !ENABLE_REWRITE */
103 } dncookie;
104
105 int rwm_dn_massage( dncookie *dc, struct berval *in, struct berval *dn );
106 int rwm_dn_massage_pretty( dncookie *dc, struct berval *in, struct berval *pdn );
107 int rwm_dn_massage_normalize( dncookie *dc, struct berval *in, struct berval *ndn );
108 int rwm_dn_massage_pretty_normalize( dncookie *dc, struct berval *in, struct berval *pdn, struct berval *ndn );
109
110 /* attributeType/objectClass mapping */
111 int rwm_mapping_cmp (const void *, const void *);
112 int rwm_mapping_dup (void *, void *);
113
114 int rwm_map_init ( struct ldapmap *lm, struct ldapmapping ** );
115 void rwm_map ( struct ldapmap *map, struct berval *s, struct berval *m,
116         int remap );
117 int rwm_mapping ( struct ldapmap *map, struct berval *s,
118                 struct ldapmapping **m, int remap );
119 #define RWM_MAP         0
120 #define RWM_REMAP       1
121 char *
122 rwm_map_filter(
123                 struct ldapmap *at_map,
124                 struct ldapmap *oc_map,
125                 struct berval *f );
126
127 int
128 rwm_map_attrs(
129                 struct ldapmap *at_map,
130                 AttributeName *a,
131                 int remap,
132                 char ***mapped_attrs );
133
134 int
135 rwm_map_attrnames(
136                 struct ldapmap *at_map,
137                 struct ldapmap *oc_map,
138                 AttributeName *an,
139                 AttributeName **anp,
140                 int remap );
141
142 extern void rwm_mapping_dst_free ( void *mapping );
143
144 extern void rwm_mapping_free ( void *mapping );
145
146 extern int rwm_map_config(
147                 struct ldapmap  *oc_map,
148                 struct ldapmap  *at_map,
149                 const char      *fname,
150                 int             lineno,
151                 int             argc,
152                 char            **argv );
153
154 extern int
155 rwm_filter_map_rewrite(
156                 Operation               *op,
157                 dncookie                *dc,
158                 Filter                  *f,
159                 struct berval           *fstr );
160
161 /* suffix massaging by means of librewrite */
162 #ifdef ENABLE_REWRITE
163 extern int rwm_suffix_massage_config( struct rewrite_info *info,
164                 struct berval *pvnc, struct berval *nvnc,
165                 struct berval *prnc, struct berval *nrnc);
166 #endif /* ENABLE_REWRITE */
167 extern int rwm_dnattr_rewrite(
168         Operation               *op,
169         SlapReply               *rs,
170         void                    *cookie,
171         BerVarray               a_vals,
172         BerVarray               *pa_nvals );
173 extern int rwm_referral_rewrite(
174         Operation               *op,
175         SlapReply               *rs,
176         void                    *cookie,
177         BerVarray               a_vals,
178         BerVarray               *pa_nvals );
179 extern int rwm_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals );
180 extern int rwm_referral_result_rewrite( dncookie *dc, BerVarray a_vals );
181
182 LDAP_END_DECL
183
184 #endif /* RWM_H */