From: Pierangelo Masarati Date: Mon, 27 Jan 2003 16:39:56 +0000 (+0000) Subject: clean up mapping api X-Git-Tag: NO_SLAP_OP_BLOCKS~490 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=45f4e3602bfae5a709c0e573c71f5fa55b77f1c3;p=openldap clean up mapping api --- diff --git a/servers/slapd/back-ldap/add.c b/servers/slapd/back-ldap/add.c index 2c5f9ac04e..0795212ee2 100644 --- a/servers/slapd/back-ldap/add.c +++ b/servers/slapd/back-ldap/add.c @@ -138,7 +138,8 @@ ldap_back_add( continue; } - ldap_back_map(&li->at_map, &a->a_desc->ad_cname, &mapped, 0); + ldap_back_map(&li->at_map, &a->a_desc->ad_cname, &mapped, + BACKLDAP_MAP); if (mapped.bv_val == NULL) { continue; } diff --git a/servers/slapd/back-ldap/attribute.c b/servers/slapd/back-ldap/attribute.c index 8c9d9f0786..a3371a5be3 100644 --- a/servers/slapd/back-ldap/attribute.c +++ b/servers/slapd/back-ldap/attribute.c @@ -63,7 +63,7 @@ ldap_back_attribute( } } - ldap_back_map(&li->at_map, &entry_at->ad_cname, &mapped, 0); + ldap_back_map(&li->at_map, &entry_at->ad_cname, &mapped, BACKLDAP_MAP); if (mapped.bv_val == NULL) { return 1; } @@ -109,7 +109,8 @@ ldap_back_attribute( else j++; } else { - ldap_back_map(&li->oc_map, &v[j], &mapped, 1); + ldap_back_map(&li->oc_map, &v[j], &mapped, + BACKLDAP_REMAP); if (mapped.bv_val) { ber_dupbv( &v[j], &mapped ); if (v[j].bv_val) diff --git a/servers/slapd/back-ldap/back-ldap.h b/servers/slapd/back-ldap/back-ldap.h index 15695231a0..eb56fce7cf 100644 --- a/servers/slapd/back-ldap/back-ldap.h +++ b/servers/slapd/back-ldap/back-ldap.h @@ -106,6 +106,8 @@ int mapping_dup (void *, void *); void ldap_back_map_init ( struct ldapmap *lm, struct ldapmapping ** ); void ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *m, int remap ); +#define BACKLDAP_MAP 0 +#define BACKLDAP_REMAP 1 char * ldap_back_map_filter( struct ldapmap *at_map, @@ -131,4 +133,4 @@ extern int ldap_dnattr_rewrite( struct rewrite_info *rwinfo, BerVarray a_vals, v LDAP_END_DECL -#endif +#endif /* SLAPD_LDAP_H */ diff --git a/servers/slapd/back-ldap/compare.c b/servers/slapd/back-ldap/compare.c index 0f18e9e4ab..9ab66e0cb3 100644 --- a/servers/slapd/back-ldap/compare.c +++ b/servers/slapd/back-ldap/compare.c @@ -100,13 +100,21 @@ ldap_back_compare( } #endif /* !ENABLE_REWRITE */ - ldap_back_map(&li->oc_map, &ava->aa_desc->ad_cname, &mapped_oc, 0); - if (mapped_oc.bv_val == NULL) - return( -1 ); - - ldap_back_map(&li->at_map, &ava->aa_value, &mapped_at, 0); - if (mapped_at.bv_val == NULL) - return( -1 ); + if ( ava->aa_desc->ad_type->sat_oid + == slap_schema.si_ad_objectClass->ad_type->sat_oid ) { + ldap_back_map(&li->oc_map, &ava->aa_desc->ad_cname, &mapped_oc, + BACKLDAP_MAP); + if (mapped_oc.bv_val == NULL || mapped_oc.bv_val[0] == '\0') { + return( -1 ); + } + + } else { + ldap_back_map(&li->at_map, &ava->aa_value, &mapped_at, + BACKLDAP_MAP); + if (mapped_at.bv_val == NULL || mapped_at.bv_val[0] == '\0') { + return( -1 ); + } + } ldap_compare_s( lc->ld, mdn.bv_val, mapped_oc.bv_val, mapped_at.bv_val ); diff --git a/servers/slapd/back-ldap/group.c b/servers/slapd/back-ldap/group.c index 284ca47165..aa413b6648 100644 --- a/servers/slapd/back-ldap/group.c +++ b/servers/slapd/back-ldap/group.c @@ -154,10 +154,12 @@ ldap_back_group( } #endif /* !ENABLE_REWRITE */ - ldap_back_map(&li->oc_map, &group_oc_name, &group_oc_name, 0); + ldap_back_map(&li->oc_map, &group_oc_name, &group_oc_name, + BACKLDAP_MAP); if (group_oc_name.bv_val == NULL) goto cleanup; - ldap_back_map(&li->at_map, &group_at_name, &group_at_name, 0); + ldap_back_map(&li->at_map, &group_at_name, &group_at_name, + BACKLDAP_MAP); if (group_at_name.bv_val == NULL) goto cleanup; diff --git a/servers/slapd/back-ldap/map.c b/servers/slapd/back-ldap/map.c index 27d1219dd3..7c46626bee 100644 --- a/servers/slapd/back-ldap/map.c +++ b/servers/slapd/back-ldap/map.c @@ -97,7 +97,7 @@ ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *bv, Avlnode *tree; struct ldapmapping *mapping, fmapping; - if (remap) + if (remap == BACKLDAP_REMAP) tree = map->remap; else tree = map->map; diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index 4b0cc04d82..d2c0ea8b83 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -118,7 +118,8 @@ ldap_back_modify( continue; } - ldap_back_map(&li->at_map, &ml->sml_desc->ad_cname, &mapped, 0); + ldap_back_map(&li->at_map, &ml->sml_desc->ad_cname, &mapped, + BACKLDAP_MAP); if (mapped.bv_val == NULL) { continue; } diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index e9f7fad4ab..41b397a9da 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -235,7 +235,7 @@ ldap_back_search( #else /* !ENABLE_REWRITE */ filterstr, #endif /* !ENABLE_REWRITE */ - 0); + BACKLDAP_MAP); if ( mapped_filter == NULL ) { #ifdef ENABLE_REWRITE mapped_filter = mfilter.bv_val; @@ -250,7 +250,7 @@ ldap_back_search( } #endif /* ENABLE_REWRITE */ - mapped_attrs = ldap_back_map_attrs(&li->at_map, attrs, 0); + mapped_attrs = ldap_back_map_attrs(&li->at_map, attrs, BACKLDAP_MAP); if ( mapped_attrs == NULL && attrs) { for (count=0; attrs[count].an_name.bv_val; count++); mapped_attrs = ch_malloc( (count+1) * sizeof(char *)); @@ -491,7 +491,7 @@ ldap_send_entry( attrp = &ent.e_attrs; while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) { - ldap_back_map(&li->at_map, &a, &mapped, 1); + ldap_back_map(&li->at_map, &a, &mapped, BACKLDAP_REMAP); if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') continue; attr = (Attribute *)ch_malloc( sizeof(Attribute) ); @@ -536,7 +536,8 @@ ldap_send_entry( for ( last = 0; attr->a_vals[last].bv_val; last++ ) ; for ( i = 0, bv = attr->a_vals; bv->bv_val; bv++, i++ ) { - ldap_back_map(&li->oc_map, bv, &mapped, 1); + ldap_back_map(&li->oc_map, bv, &mapped, + BACKLDAP_REMAP); if (mapped.bv_val == NULL || mapped.bv_val[0] == '\0') { LBER_FREE(bv->bv_val); bv->bv_val = NULL; diff --git a/servers/slapd/back-meta/add.c b/servers/slapd/back-meta/add.c index 1b25546d9e..1b672ef4de 100644 --- a/servers/slapd/back-meta/add.c +++ b/servers/slapd/back-meta/add.c @@ -154,7 +154,7 @@ meta_back_add( } ldap_back_map( &li->targets[ candidate ]->at_map, - &a->a_desc->ad_cname, &mapped, 0); + &a->a_desc->ad_cname, &mapped, BACKLDAP_MAP ); if ( mapped.bv_val == NULL ) { continue; } diff --git a/servers/slapd/back-meta/attribute.c b/servers/slapd/back-meta/attribute.c index 7b7a0b1d97..c3f9d6e5b9 100644 --- a/servers/slapd/back-meta/attribute.c +++ b/servers/slapd/back-meta/attribute.c @@ -140,7 +140,7 @@ meta_back_attribute( } ldap_back_map( &li->targets[ candidate ]->at_map, - &entry_at->ad_cname, &mapped, 0 ); + &entry_at->ad_cname, &mapped, BACKLDAP_MAP ); if ( mapped.bv_val == NULL ) return 1; @@ -181,7 +181,7 @@ meta_back_attribute( j++; } } else { - ldap_back_map( &li->targets[ candidate ]->oc_map, &v[ j ], &mapped, 1 ); + ldap_back_map( &li->targets[ candidate ]->oc_map, &v[ j ], &mapped, BACKLDAP_REMAP ); if ( mapped.bv_val ) { ber_dupbv( &v[ j ], &mapped ); if ( v[ j ].bv_val ) { diff --git a/servers/slapd/back-meta/compare.c b/servers/slapd/back-meta/compare.c index cc5b40530c..9c6d803783 100644 --- a/servers/slapd/back-meta/compare.c +++ b/servers/slapd/back-meta/compare.c @@ -156,9 +156,10 @@ meta_back_compare( if ( ava->aa_desc->ad_type->sat_oid == slap_schema.si_ad_objectClass->ad_type->sat_oid ) { ldap_back_map( &li->targets[ i ]->oc_map, - &ava->aa_value, &mapped_value, 0 ); + &ava->aa_value, &mapped_value, + BACKLDAP_MAP ); - if ( mapped_value.bv_val == NULL ) { + if ( mapped_value.bv_val == NULL || mapped_value.bv_val[0] == '\0' ) { continue; } /* @@ -166,8 +167,9 @@ meta_back_compare( */ } else { ldap_back_map( &li->targets[ i ]->at_map, - &ava->aa_desc->ad_cname, &mapped_attr, 0 ); - if ( mapped_attr.bv_val == NULL ) { + &ava->aa_desc->ad_cname, &mapped_attr, + BACKLDAP_MAP ); + if ( mapped_attr.bv_val == NULL || mapped_attr.bv_val[0] == '\0' ) { continue; } } diff --git a/servers/slapd/back-meta/group.c b/servers/slapd/back-meta/group.c index e989069a9a..990ff8bc9c 100644 --- a/servers/slapd/back-meta/group.c +++ b/servers/slapd/back-meta/group.c @@ -222,12 +222,12 @@ meta_back_group( } ldap_back_map( &li->targets[ candidate ]->oc_map, - &group_oc_name, &group_oc_name, 0 ); + &group_oc_name, &group_oc_name, BACKLDAP_MAP ); if ( group_oc_name.bv_val == NULL ) { goto cleanup; } ldap_back_map( &li->targets[ candidate ]->at_map, - &group_at_name, &group_at_name, 0 ); + &group_at_name, &group_at_name, BACKLDAP_MAP ); if ( group_at_name.bv_val == NULL ) { goto cleanup; } diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index 230d1eee90..773b5bdb07 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -158,7 +158,8 @@ meta_back_modify( } ldap_back_map( &li->targets[ candidate ]->at_map, - &ml->sml_desc->ad_cname, &mapped, 0 ); + &ml->sml_desc->ad_cname, &mapped, + BACKLDAP_MAP ); if ( mapped.bv_val == NULL ) { continue; } diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index feea9132d8..1243ba0f28 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -357,7 +357,8 @@ meta_back_search( * Maps attributes in filter */ mapped_filter = ldap_back_map_filter( &li->targets[ i ]->at_map, - &li->targets[ i ]->oc_map, &mfilter, 0 ); + &li->targets[ i ]->oc_map, &mfilter, + BACKLDAP_MAP ); if ( mapped_filter == NULL ) { mapped_filter = ( char * )mfilter.bv_val; } else { @@ -372,7 +373,7 @@ meta_back_search( * Maps required attributes */ mapped_attrs = ldap_back_map_attrs( &li->targets[ i ]->at_map, - attrs, 0 ); + attrs, BACKLDAP_MAP ); if ( mapped_attrs == NULL && attrs) { for ( count=0; attrs[ count ].an_name.bv_val; count++ ); mapped_attrs = ch_malloc( ( count + 1 ) * sizeof(char *)); @@ -726,7 +727,7 @@ meta_send_entry( while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) { ldap_back_map( &li->targets[ target ]->at_map, - &a, &mapped, 1 ); + &a, &mapped, BACKLDAP_REMAP ); if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0' ) { continue; } @@ -770,7 +771,7 @@ meta_send_entry( for ( last = 0; attr->a_vals[ last ].bv_val; ++last ); for ( i = 0, bv = attr->a_vals; bv->bv_val; bv++, i++ ) { ldap_back_map( &li->targets[ target]->oc_map, - bv, &mapped, 1 ); + bv, &mapped, BACKLDAP_REMAP ); if ( mapped.bv_val == NULL || mapped.bv_val[0] == '\0') { free( bv->bv_val ); bv->bv_val = NULL;