Debian Codegraph @

servers/slapd/overlays/rwm.h

raw
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-2024 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 #include "rewrite.h"
29
30 LDAP_BEGIN_DECL
31
32 /* define to enable referral DN massage by default */
33 #undef RWM_REFERRAL_REWRITE
34
35 struct ldapmap {
36 int drop_missing;
37
38 Avlnode *map;
39 Avlnode *remap;
40 };
41
42 struct ldapmapping {
43 int m_flags;
44 #define RWMMAP_F_NONE 0x00
45 #define RWMMAP_F_IS_OC 0x01
46 #define RWMMAP_F_FREE_SRC 0x10
47 #define RWMMAP_F_FREE_DST 0x20
48 struct berval m_src;
49 union {
50 AttributeDescription *m_s_ad;
51 ObjectClass *m_s_oc;
52 } m_src_ref;
53 #define m_src_ad m_src_ref.m_s_ad
54 #define m_src_oc m_src_ref.m_s_oc
55 struct berval m_dst;
56 union {
57 AttributeDescription *m_d_ad;
58 ObjectClass *m_d_oc;
59 } m_dst_ref;
60 #define m_dst_ad m_dst_ref.m_d_ad
61 #define m_dst_oc m_dst_ref.m_d_oc
62 };
63
64 struct ldaprwmap {
65 /*
66 * DN rewriting
67 */
68 struct rewrite_info *rwm_rw;
69 BerVarray rwm_bva_rewrite;
70
71 /*
72 * Attribute/objectClass mapping
73 */
74 struct ldapmap rwm_oc;
75 struct ldapmap rwm_at;
76 BerVarray rwm_bva_map;
77
78 #define RWM_F_NONE (0x0000U)
79 #define RWM_F_NORMALIZE_MAPPED_ATTRS (0x0001U)
80 #define RWM_F_DROP_UNREQUESTED_ATTRS (0x0002U)
81 #define RWM_F_SUPPORT_T_F (0x4000U)
82 #define RWM_F_SUPPORT_T_F_DISCOVER (0x8000U)
83 #define RWM_F_SUPPORT_T_F_MASK (RWM_F_SUPPORT_T_F)
84 #define RWM_F_SUPPORT_T_F_MASK2 (RWM_F_SUPPORT_T_F|RWM_F_SUPPORT_T_F_DISCOVER)
85 unsigned rwm_flags;
86 };
87
88 /* Whatever context ldap_back_dn_massage needs... */
89 typedef struct dncookie {
90 struct ldaprwmap *rwmap;
91
92 Connection *conn;
93 char *ctx;
94 SlapReply *rs;
95 } dncookie;
96
97 int rwm_dn_massage( dncookie *dc, struct berval *in, struct berval *dn );
98 int rwm_dn_massage_pretty( dncookie *dc, struct berval *in, struct berval *pdn );
99 int rwm_dn_massage_normalize( dncookie *dc, struct berval *in, struct berval *ndn );
100 int rwm_dn_massage_pretty_normalize( dncookie *dc, struct berval *in, struct berval *pdn, struct berval *ndn );
101
102 /* attributeType/objectClass mapping */
103 int rwm_mapping_cmp (const void *, const void *);
104 int rwm_mapping_dup (void *, void *);
105
106 int rwm_map_init ( struct ldapmap *lm, struct ldapmapping ** );
107 void rwm_map ( struct ldapmap *map, struct berval *s, struct berval *m,
108 int remap );
109 int rwm_mapping ( struct ldapmap *map, struct berval *s,
110 struct ldapmapping **m, int remap );
111 #define RWM_MAP 0
112 #define RWM_REMAP 1
113 char *
114 rwm_map_filter(
115 struct ldapmap *at_map,
116 struct ldapmap *oc_map,
117 struct berval *f );
118
119 #if 0 /* unused! */
120 int
121 rwm_map_attrs(
122 struct ldapmap *at_map,
123 AttributeName *a,
124 int remap,
125 char ***mapped_attrs );
126 #endif
127
128 int
129 rwm_map_attrnames(
130 Operation *op,
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, BerVarray a_nvals );
179 extern int rwm_referral_result_rewrite( dncookie *dc, BerVarray a_vals );
180
181 LDAP_END_DECL
182
183 #endif /* RWM_H */