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