]> git.sur5r.net Git - openldap/commitdiff
clean up mapping api
authorPierangelo Masarati <ando@openldap.org>
Mon, 27 Jan 2003 16:39:56 +0000 (16:39 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 27 Jan 2003 16:39:56 +0000 (16:39 +0000)
14 files changed:
servers/slapd/back-ldap/add.c
servers/slapd/back-ldap/attribute.c
servers/slapd/back-ldap/back-ldap.h
servers/slapd/back-ldap/compare.c
servers/slapd/back-ldap/group.c
servers/slapd/back-ldap/map.c
servers/slapd/back-ldap/modify.c
servers/slapd/back-ldap/search.c
servers/slapd/back-meta/add.c
servers/slapd/back-meta/attribute.c
servers/slapd/back-meta/compare.c
servers/slapd/back-meta/group.c
servers/slapd/back-meta/modify.c
servers/slapd/back-meta/search.c

index 2c5f9ac04eddd3d16ddfbb3074c4e61ee5058544..0795212ee2ba774183c5bfbdee282a7b81586d78 100644 (file)
@@ -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;
                }
index 8c9d9f078604fc99855970a806724c39266e29db..a3371a5be3ce3c4e14c8ca5ec3ed64cfd734a88b 100644 (file)
@@ -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)
index 15695231a0969ebe8787b839176164e84aaf33aa..eb56fce7cf59dbb51051ca49589007b1499a6b64 100644 (file)
@@ -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 */
index 0f18e9e4ab996fcb8d201eedb305d5d5fd6e2786..9ab66e0cb329ceb4fd7ec6657498df04f81e992d 100644 (file)
@@ -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 );
 
index 284ca4716582a3c715ef67d028edfa7d63f1a05d..aa413b66482783f45d722d6b7333534e0672e6dc 100644 (file)
@@ -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;
 
index 27d1219dd3ddaa979538aa0a28685faac7c131a4..7c46626beea52172f3a137126dd72f838176535f 100644 (file)
@@ -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;
index 4b0cc04d8277267306d1e73a4bfd51cabaecaed9..d2c0ea8b83c13b3af4f17377fe923f81205b2aee 100644 (file)
@@ -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;
                }
index e9f7fad4abdab0fc60bfefe4226920fc3297c979..41b397a9da22dd2cdef2c9535414219f59671768 100644 (file)
@@ -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;
index 1b25546d9e87339feb975f712953a1b89f1ae008..1b672ef4de8350dc784ae8a132d6424318efc18f 100644 (file)
@@ -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;
                }
index 7b7a0b1d9785bfbbdf52040deaeb4edc076a45c6..c3f9d6e5b99af42d90e84de6613c5a7d8897dffb 100644 (file)
@@ -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 ) {
index cc5b40530c20f3fba7bc235267dd257184350d83..9c6d803783f89c628de0692ca8792875babe8b32 100644 (file)
@@ -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;
                        }
                }
index e989069a9adbba336f945feda08de2af178ec70d..990ff8bc9c94f8dd90c5673f9c5dadea2957b0df 100644 (file)
@@ -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;
        }
index 230d1eee90aabc7485481d72469f46066de1a8f5..773b5bdb07a73585e94ad16eec0ccd27985d8c98 100644 (file)
@@ -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;
                }
index feea9132d8c153f38f9728905454400c2f1d7aa2..1243ba0f288e21d7775ef67efeb029e34bd75f88 100644 (file)
@@ -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;