Back to index

openldap  2.4.31
rwm.h
Go to the documentation of this file.
00001 /* rwm.h - dn rewrite/attribute mapping header file */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1999-2012 The OpenLDAP Foundation.
00006  * Portions Copyright 1999-2003 Howard Chu.
00007  * Portions Copyright 2000-2003 Pierangelo Masarati.
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without
00011  * modification, are permitted only as authorized by the OpenLDAP
00012  * Public License.
00013  *
00014  * A copy of this license is available in the file LICENSE in the
00015  * top-level directory of the distribution or, alternatively, at
00016  * <http://www.OpenLDAP.org/license.html>.
00017  */
00018 /* ACKNOWLEDGEMENTS:
00019  * This work was initially developed by the Howard Chu for inclusion
00020  * in OpenLDAP Software and subsequently enhanced by Pierangelo
00021  * Masarati.
00022  */
00023 
00024 #ifndef RWM_H
00025 #define RWM_H
00026 
00027 #ifndef ENABLE_REWRITE
00028 #error "librewrite must be enabled!"
00029 #endif /* ENABLE_REWRITE */
00030 
00031 /* String rewrite library */
00032 #include "rewrite.h"
00033 
00034 LDAP_BEGIN_DECL
00035 
00036 /* define to enable referral DN massage by default */
00037 #undef RWM_REFERRAL_REWRITE
00038 
00039 struct ldapmap {
00040        int drop_missing;
00041 
00042        Avlnode *map;
00043        Avlnode *remap;
00044 };
00045 
00046 struct ldapmapping {
00047        int                  m_flags;
00048 #define       RWMMAP_F_NONE        0x00
00049 #define       RWMMAP_F_IS_OC              0x01
00050 #define RWMMAP_F_FREE_SRC   0x10
00051 #define RWMMAP_F_FREE_DST   0x20
00052        struct berval        m_src;
00053        union {
00054               AttributeDescription *m_s_ad;
00055               ObjectClass          *m_s_oc;
00056        } m_src_ref;
00057 #define m_src_ad     m_src_ref.m_s_ad
00058 #define m_src_oc     m_src_ref.m_s_oc
00059        struct berval        m_dst;
00060        union {
00061               AttributeDescription *m_d_ad;
00062               ObjectClass          *m_d_oc;
00063        } m_dst_ref;
00064 #define m_dst_ad     m_dst_ref.m_d_ad
00065 #define m_dst_oc     m_dst_ref.m_d_oc
00066 };
00067 
00068 struct ldaprwmap {
00069        /*
00070         * DN rewriting
00071         */
00072        struct rewrite_info *rwm_rw;
00073        BerVarray rwm_bva_rewrite;
00074 
00075        /*
00076         * Attribute/objectClass mapping
00077         */
00078        struct ldapmap rwm_oc;
00079        struct ldapmap rwm_at;
00080        BerVarray rwm_bva_map;
00081 
00082 #define       RWM_F_NONE                  (0x0000U)
00083 #define       RWM_F_NORMALIZE_MAPPED_ATTRS    (0x0001U)
00084 #define       RWM_F_DROP_UNREQUESTED_ATTRS       (0x0002U)
00085 #define       RWM_F_SUPPORT_T_F           (0x4000U)
00086 #define       RWM_F_SUPPORT_T_F_DISCOVER  (0x8000U)
00087 #define       RWM_F_SUPPORT_T_F_MASK             (RWM_F_SUPPORT_T_F)
00088 #define       RWM_F_SUPPORT_T_F_MASK2            (RWM_F_SUPPORT_T_F|RWM_F_SUPPORT_T_F_DISCOVER)
00089        unsigned      rwm_flags;
00090 };
00091 
00092 /* Whatever context ldap_back_dn_massage needs... */
00093 typedef struct dncookie {
00094        struct ldaprwmap *rwmap;
00095 
00096        Connection *conn;
00097        char *ctx;
00098        SlapReply *rs;
00099 } dncookie;
00100 
00101 int rwm_dn_massage( dncookie *dc, struct berval *in, struct berval *dn );
00102 int rwm_dn_massage_pretty( dncookie *dc, struct berval *in, struct berval *pdn );
00103 int rwm_dn_massage_normalize( dncookie *dc, struct berval *in, struct berval *ndn );
00104 int rwm_dn_massage_pretty_normalize( dncookie *dc, struct berval *in, struct berval *pdn, struct berval *ndn );
00105 
00106 /* attributeType/objectClass mapping */
00107 int rwm_mapping_cmp (const void *, const void *);
00108 int rwm_mapping_dup (void *, void *);
00109 
00110 int rwm_map_init ( struct ldapmap *lm, struct ldapmapping ** );
00111 void rwm_map ( struct ldapmap *map, struct berval *s, struct berval *m,
00112        int remap );
00113 int rwm_mapping ( struct ldapmap *map, struct berval *s,
00114               struct ldapmapping **m, int remap );
00115 #define RWM_MAP             0
00116 #define RWM_REMAP    1
00117 char *
00118 rwm_map_filter(
00119               struct ldapmap *at_map,
00120               struct ldapmap *oc_map,
00121               struct berval *f );
00122 
00123 #if 0 /* unused! */
00124 int
00125 rwm_map_attrs(
00126               struct ldapmap *at_map,
00127               AttributeName *a,
00128               int remap,
00129               char ***mapped_attrs );
00130 #endif
00131 
00132 int
00133 rwm_map_attrnames(
00134               Operation *op,
00135               struct ldapmap *at_map,
00136               struct ldapmap *oc_map,
00137               AttributeName *an,
00138               AttributeName **anp,
00139               int remap );
00140 
00141 extern void rwm_mapping_dst_free ( void *mapping );
00142 
00143 extern void rwm_mapping_free ( void *mapping );
00144 
00145 extern int rwm_map_config(
00146               struct ldapmap       *oc_map,
00147               struct ldapmap       *at_map,
00148               const char    *fname,
00149               int           lineno,
00150               int           argc,
00151               char          **argv );
00152 
00153 extern int
00154 rwm_filter_map_rewrite(
00155               Operation            *op,
00156               dncookie             *dc,
00157               Filter               *f,
00158               struct berval        *fstr );
00159 
00160 /* suffix massaging by means of librewrite */
00161 extern int
00162 rwm_suffix_massage_config(
00163        struct rewrite_info  *info,
00164        struct berval        *pvnc,
00165        struct berval        *nvnc,
00166        struct berval        *prnc,
00167        struct berval        *nrnc);
00168 extern int
00169 rwm_dnattr_rewrite(
00170        Operation            *op,
00171        SlapReply            *rs,
00172        void                 *cookie,
00173        BerVarray            a_vals,
00174        BerVarray            *pa_nvals );
00175 extern int
00176 rwm_referral_rewrite(
00177        Operation            *op,
00178        SlapReply            *rs,
00179        void                 *cookie,
00180        BerVarray            a_vals,
00181        BerVarray            *pa_nvals );
00182 extern int rwm_dnattr_result_rewrite( dncookie *dc, BerVarray a_vals, BerVarray a_nvals );
00183 extern int rwm_referral_result_rewrite( dncookie *dc, BerVarray a_vals );
00184 
00185 LDAP_END_DECL
00186 
00187 #endif /* RWM_H */