mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-03 13:40:37 -05:00
clean up mapping api
This commit is contained in:
parent
c1f84b5031
commit
45f4e3602b
14 changed files with 53 additions and 33 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue