]> git.sur5r.net Git - openldap/commitdiff
pretty the DN as well
authorPierangelo Masarati <ando@openldap.org>
Tue, 6 Sep 2005 17:19:36 +0000 (17:19 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 6 Sep 2005 17:19:36 +0000 (17:19 +0000)
servers/slapd/back-meta/search.c

index 55edc25767777b32ecacfee03d01f4637ee8e16f..f1521b9b92ee502c0d60f7490c4825857a2563d9 100644 (file)
@@ -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 ) ) {