From a1ff59f436fae2410afd65fab402e9a5eb3039ab Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 6 Sep 2005 17:19:36 +0000 Subject: [PATCH] pretty the DN as well --- servers/slapd/back-meta/search.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 55edc25767..f1521b9b92 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -867,9 +867,11 @@ meta_send_entry( Entry ent = { 0 }; BerElement ber = *e->lm_ber; Attribute *attr, **attrp; - struct berval *bv, bdn; + struct berval bdn, + dn = BER_BVNULL; const char *text; dncookie dc; + int rc; if ( ber_scanf( &ber, "{m{", &bdn ) == LBER_ERROR ) { return LDAP_DECODING_ERROR; @@ -883,7 +885,7 @@ meta_send_entry( dc.rs = rs; dc.ctx = "searchResult"; - rs->sr_err = ldap_back_dn_massage( &dc, &bdn, &ent.e_name ); + rs->sr_err = ldap_back_dn_massage( &dc, &bdn, &dn ); if ( rs->sr_err != LDAP_SUCCESS) { return rs->sr_err; } @@ -895,9 +897,14 @@ meta_send_entry( * * FIXME: should we log anything, or delegate to dnNormalize? */ - if ( dnNormalize( 0, NULL, NULL, &ent.e_name, &ent.e_nname, - op->o_tmpmemctx ) != LDAP_SUCCESS ) - { + rc = dnPrettyNormal( NULL, &dn, &ent.e_name, &ent.e_nname, + op->o_tmpmemctx ); + if ( dn.bv_val != bdn.bv_val ) { + free( dn.bv_val ); + } + BER_BVZERO( &dn ); + + if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_DN_SYNTAX; } @@ -992,6 +999,8 @@ meta_send_entry( if ( attr->a_desc == slap_schema.si_ad_objectClass || attr->a_desc == slap_schema.si_ad_structuralObjectClass ) { + struct berval *bv; + for ( bv = attr->a_vals; !BER_BVISNULL( bv ); bv++ ) { ldap_back_map( &mi->mi_targets[ target ].mt_rwmap.rwm_oc, bv, &mapped, BACKLDAP_REMAP ); @@ -1084,9 +1093,7 @@ next_attr:; rs->sr_attrs = NULL; if ( !BER_BVISNULL( &ent.e_name ) ) { - if ( ent.e_name.bv_val != bdn.bv_val ) { - free( ent.e_name.bv_val ); - } + free( ent.e_name.bv_val ); BER_BVZERO( &ent.e_name ); } if ( !BER_BVISNULL( &ent.e_nname ) ) { -- 2.39.5