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