rwm.h revision 1.1.1.10 1 /* $NetBSD: rwm.h,v 1.1.1.10 2025/09/05 21:09:49 christos Exp $ */
2
3 /* rwm.h - dn rewrite/attribute mapping header file */
4 /* $OpenLDAP$ */
5 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
6 *
7 * Copyright 1999-2024 The OpenLDAP Foundation.
8 * Portions Copyright 1999-2003 Howard Chu.
9 * Portions Copyright 2000-2003 Pierangelo Masarati.
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted only as authorized by the OpenLDAP
14 * Public License.
15 *
16 * A copy of this license is available in the file LICENSE in the
17 * top-level directory of the distribution or, alternatively, at
18 * <http://www.OpenLDAP.org/license.html>.
19 */
20 /* ACKNOWLEDGEMENTS:
21 * This work was initially developed by the Howard Chu for inclusion
22 * in OpenLDAP Software and subsequently enhanced by Pierangelo
23 * Masarati.
24 */
25
26 #ifndef RWM_H
27 #define RWM_H
28
29 /* String rewrite library */
30 #include "rewrite.h"
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 struct rewrite_info *rwm_rw;
71 BerVarray rwm_bva_rewrite;
72
73 /*
74 * Attribute/objectClass mapping
75 */
76 struct ldapmap rwm_oc;
77 struct ldapmap rwm_at;
78 BerVarray rwm_bva_map;
79
80 #define RWM_F_NONE (0x0000U)
81 #define RWM_F_NORMALIZE_MAPPED_ATTRS (0x0001U)
82 #define RWM_F_DROP_UNREQUESTED_ATTRS (0x0002U)
83 #define RWM_F_SUPPORT_T_F (0x4000U)
84 #define RWM_F_SUPPORT_T_F_DISCOVER (0x8000U)
85 #define RWM_F_SUPPORT_T_F_MASK (RWM_F_SUPPORT_T_F)
86 #define RWM_F_SUPPORT_T_F_MASK2 (RWM_F_SUPPORT_T_F|RWM_F_SUPPORT_T_F_DISCOVER)
87 unsigned rwm_flags;
88 };
89
90 /* Whatever context ldap_back_dn_massage needs... */
91 typedef struct dncookie {
92 struct ldaprwmap *rwmap;
93
94 Connection *conn;
95 char *ctx;
96 SlapReply *rs;
97 } dncookie;
98
99 int rwm_dn_massage( dncookie *dc, struct berval *in, struct berval *dn );
100 int rwm_dn_massage_pretty( dncookie *dc, struct berval *in, struct berval *pdn );
101 int rwm_dn_massage_normalize( dncookie *dc, struct berval *in, struct berval *ndn );
102 int rwm_dn_massage_pretty_normalize( dncookie *dc, struct berval *in, struct berval *pdn, struct berval *ndn );
103
104 /* attributeType/objectClass mapping */
105 int rwm_mapping_cmp (const void *, const void *);
106 int rwm_mapping_dup (void *, void *);
107
108 int rwm_map_init ( struct ldapmap *lm, struct ldapmapping ** );
109 void rwm_map ( struct ldapmap *map, struct berval *s, struct berval *m,
110 int remap );
111 int rwm_mapping ( struct ldapmap *map, struct berval *s,
112 struct ldapmapping **m, int remap );
113 #define RWM_MAP 0
114 #define RWM_REMAP 1
115 char *
116 rwm_map_filter(
117 struct ldapmap *at_map,
118 struct ldapmap *oc_map,
119 struct berval *f );
120
121 #if 0 /* unused! */
122 int
123 rwm_map_attrs(
124 struct ldapmap *at_map,
125 AttributeName *a,
126 int remap,
127 char ***mapped_attrs );
128 #endif
129
130 int
131 rwm_map_attrnames(
132 Operation *op,
133 struct ldapmap *at_map,
134 struct ldapmap *oc_map,
135 AttributeName *an,
136 AttributeName **anp,
137 int remap );
138
139 extern void rwm_mapping_dst_free ( void *mapping );
140
141 extern void rwm_mapping_free ( void *mapping );
142
143 extern int rwm_map_config(
144 struct ldapmap *oc_map,
145 struct ldapmap *at_map,
146 const char *fname,
147 int lineno,
148 int argc,
149 char **argv );
150
151 extern int
152 rwm_filter_map_rewrite(
153 Operation *op,
154 dncookie *dc,
155 Filter *f,
156 struct berval *fstr );
157
158 /* suffix massaging by means of librewrite */
159 extern int
160 rwm_suffix_massage_config(
161 struct rewrite_info *info,
162 struct berval *pvnc,
163 struct berval *nvnc,
164 struct berval *prnc,
165 struct berval *nrnc);
166 extern int
167 rwm_dnattr_rewrite(
168 Operation *op,
169 SlapReply *rs,
170 void *cookie,
171 BerVarray a_vals,
172 BerVarray *pa_nvals );
173 extern int
174 rwm_referral_rewrite(
175 Operation *op,
176 SlapReply *rs,
177 void *cookie,
178 BerVarray a_vals,
179 BerVarray *pa_nvals );
180 extern int rwm_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals, BerVarray a_nvals );
181 extern int rwm_referral_result_rewrite( dncookie *dc, BerVarray a_vals );
182
183 LDAP_END_DECL
184
185 #endif /* RWM_H */
186