]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/result.c
use a separate field for a modified entry in SlapReply
[openldap] / servers / slapd / result.c
index 74238529414f6ed4c9f7b8c1919e2d5580dcdb1c..a2020ff5ae5aa607cae7c33ff11fda8619a5e35c 100644 (file)
@@ -746,7 +746,8 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
         *          returned or filtered out
         * e_flags: array of a_flags
         */
-       char **e_flags = NULL;
+       char            **e_flags = NULL;
+       Entry           *e;
 
        rs->sr_type = REP_SEARCH;
        if (op->o_callback) {
@@ -763,21 +764,23 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                if ( rc != SLAP_CB_CONTINUE ) goto error_return;
        }
 
+       e = rs->sr_mentry ? rs->sr_mentry : rs->sr_entry;
+
 #ifdef NEW_LOGGING
-       LDAP_LOG( OPERATION, ENTRY, "send_search_entry: conn %lu        dn=\"%s\"%s\n",
-               op->o_connid, rs->sr_entry->e_name.bv_val,
+       LDAP_LOG( OPERATION, ENTRY, "send_search_entry: conn %lu dn=\"%s\"%s\n",
+               op->o_connid, e->e_name.bv_val,
                op->ors_attrsonly ? " (attrsOnly)" : "" );
 #else
-       Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: dn=\"%s\"%s\n",
-               rs->sr_entry->e_name.bv_val,
-               op->ors_attrsonly ? " (attrsOnly)" : "", 0 );
+       Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: conn %lu dn=\"%s\"%s\n",
+               op->o_connid, e->e_name.bv_val,
+               op->ors_attrsonly ? " (attrsOnly)" : "" );
 #endif
 
-       if ( !access_allowed( op, rs->sr_entry, ad_entry, NULL, ACL_READ, NULL )) {
+       if ( !access_allowed( op, e, ad_entry, NULL, ACL_READ, NULL )) {
 #ifdef NEW_LOGGING
                LDAP_LOG( ACL, INFO, 
                        "send_search_entry: conn %lu access to entry (%s) not allowed\n", 
-                       op->o_connid, rs->sr_entry->e_name.bv_val, 0 );
+                       op->o_connid, e->e_name.bv_val, 0 );
 #else
                Debug( LDAP_DEBUG_ACL,
                        "send_search_entry: access to entry not allowed\n",
@@ -788,16 +791,17 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                goto error_return;
        }
 
-       edn = rs->sr_entry->e_nname.bv_val;
+       edn = e->e_nname.bv_val;
 
        if ( op->o_res_ber ) {
                /* read back control or LDAP_CONNECTIONLESS */
-           ber = op->o_res_ber;
+               ber = op->o_res_ber;
+
        } else {
                ber_len_t       siz, len;
                struct berval   bv;
 
-               entry_flatsize( rs->sr_entry, &siz, &len, 0 );
+               entry_flatsize( e, &siz, &len, 0 );
                bv.bv_len = siz + len;
                bv.bv_val = op->o_tmpalloc(bv.bv_len, op->o_tmpmemctx );
 
@@ -809,20 +813,20 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
        if ( op->o_conn && op->o_conn->c_is_udp ) {
                /* CONNECTIONLESS */
                if ( op->o_protocol == LDAP_VERSION2 ) {
-               rc = ber_printf(ber, "t{O{" /*}}*/,
-                               LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
+                       rc = ber_printf(ber, "t{O{" /*}}*/,
+                               LDAP_RES_SEARCH_ENTRY, &e->e_name );
                } else {
-               rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
-                               LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
+                       rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
+                               LDAP_RES_SEARCH_ENTRY, &e->e_name );
                }
        } else
 #endif
        if ( op->o_res_ber ) {
                /* read back control */
-           rc = ber_printf( ber, "{O{" /*}}*/, &rs->sr_entry->e_name );
+               rc = ber_printf( ber, "{O{" /*}}*/, &e->e_name );
        } else {
-           rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
-                       LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
+               rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
+                       LDAP_RES_SEARCH_ENTRY, &e->e_name );
        }
 
        if ( rc == -1 ) {
@@ -855,7 +859,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                int     k = 0;
                size_t  size;
 
-               for ( a = rs->sr_entry->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
+               for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
                        for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) k++;
                }
 
@@ -879,13 +883,13 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                        }
                        a_flags = (char *)(e_flags + i);
                        memset( a_flags, 0, k );
-                       for ( a=rs->sr_entry->e_attrs, i=0; a != NULL; a=a->a_next, i++ ) {
+                       for ( a = e->e_attrs, i = 0; a != NULL; a = a->a_next, i++ ) {
                                for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
                                e_flags[i] = a_flags;
                                a_flags += j;
                        }
        
-                       rc = filter_matched_values(op, rs->sr_entry->e_attrs, &e_flags) ; 
+                       rc = filter_matched_values(op, e->e_attrs, &e_flags) ; 
                        if ( rc == -1 ) {
 #ifdef NEW_LOGGING
                                LDAP_LOG( OPERATION, ERR, "send_search_entry: "
@@ -903,7 +907,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                }
        }
 
-       for ( a = rs->sr_entry->e_attrs, j = 0; a != NULL; a = a->a_next, j++ ) {
+       for ( a = e->e_attrs, j = 0; a != NULL; a = a->a_next, j++ ) {
                AttributeDescription *desc = a->a_desc;
                int finish = 0;
 
@@ -928,7 +932,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                }
 
                if ( op->ors_attrsonly ) {
-                       if ( ! access_allowed( op, rs->sr_entry, desc, NULL,
+                       if ( ! access_allowed( op, e, desc, NULL,
                                ACL_READ, &acl_state ) )
                        {
 #ifdef NEW_LOGGING
@@ -962,7 +966,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                } else {
                        int first = 1;
                        for ( i = 0; a->a_nvals[i].bv_val != NULL; i++ ) {
-                               if ( ! access_allowed( op, rs->sr_entry,
+                               if ( ! access_allowed( op, e,
                                        desc, &a->a_nvals[i], ACL_READ, &acl_state ) )
                                {
 #ifdef NEW_LOGGING
@@ -1126,7 +1130,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                        }
                }
 
-               if ( ! access_allowed( op, rs->sr_entry, desc, NULL,
+               if ( ! access_allowed( op, e, desc, NULL,
                        ACL_READ, &acl_state ) )
                {
 #ifdef NEW_LOGGING
@@ -1163,7 +1167,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
 
                if ( ! op->ors_attrsonly ) {
                        for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
-                               if ( ! access_allowed( op, rs->sr_entry,
+                               if ( ! access_allowed( op, e,
                                        desc, &a->a_vals[i], ACL_READ, &acl_state ) )
                                {
 #ifdef NEW_LOGGING
@@ -1240,7 +1244,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                if ( rs->sr_attrs != NULL ) {
                        for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) {
                                rc = compute_evaluator( &ctx, anp->an_name.bv_val,
-                                       rs->sr_entry, slapi_int_compute_output_ber );
+                                       e, slapi_int_compute_output_ber );
                                if ( rc == 1 ) break;
                        }
                } else {
@@ -1250,7 +1254,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                         * plugin decide whether to be naughty or not.
                         */
                        rc = compute_evaluator( &ctx, "*",
-                               rs->sr_entry, slapi_int_compute_output_ber );
+                               e, slapi_int_compute_output_ber );
                }
                if ( rc == 1 ) {
                        if ( op->o_res_ber == NULL ) ber_free_buf( ber );
@@ -1329,7 +1333,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
        }
 
        Statslog( LDAP_DEBUG_STATS2, "conn=%lu op=%lu ENTRY dn=\"%s\"\n",
-           op->o_connid, op->o_opid, rs->sr_entry->e_dn, 0, 0 );
+           op->o_connid, op->o_opid, e->e_dn, 0, 0 );
 
 #ifdef NEW_LOGGING
        LDAP_LOG( OPERATION, ENTRY,