]> git.sur5r.net Git - openldap/commitdiff
fix ITS#5717
authorPierangelo Masarati <ando@openldap.org>
Mon, 29 Sep 2008 18:45:39 +0000 (18:45 +0000)
committerPierangelo Masarati <ando@openldap.org>
Mon, 29 Sep 2008 18:45:39 +0000 (18:45 +0000)
servers/slapd/overlays/dynlist.c

index 647a2ca6c33265fa0e6972cb14d3f65f238f814e..71c0eb0b3a3666393b142c0ddf6ad4723e8de532 100644 (file)
@@ -371,8 +371,8 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
 
        /* Don't generate member list if it wasn't requested */
        for ( dlm = dli->dli_dlm; dlm; dlm = dlm->dlm_next ) {
-               if ( userattrs ||
-                    ad_inlist( dlm->dlm_member_ad, rs->sr_attrs ) ) 
+               AttributeDescription *ad = dlm->dlm_mapped_ad ? dlm->dlm_mapped_ad : dlm->dlm_member_ad;
+               if ( userattrs || ad_inlist( ad, rs->sr_attrs ) ) 
                        break;
        }
        if ( dli->dli_dlm && !dlm )
@@ -423,7 +423,6 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
                int             i, j;
                struct berval   dn;
                int             rc;
-               dynlist_map_t   *dlm;
 
                BER_BVZERO( &o.o_req_dn );
                BER_BVZERO( &o.o_req_ndn );
@@ -500,17 +499,42 @@ dynlist_prepare_entry( Operation *op, SlapReply *rs, dynlist_info_t *dli )
                                        if ( o.ors_attrs[j].an_desc != NULL &&
                                                        is_at_operational( o.ors_attrs[j].an_desc->ad_type ) )
                                        {
-                                               if ( !opattrs && !ad_inlist( o.ors_attrs[j].an_desc, rs->sr_attrs ) )
-                                               {
+                                               if ( !opattrs ) {
                                                        continue;
                                                }
 
+                                               if ( !ad_inlist( o.ors_attrs[j].an_desc, rs->sr_attrs ) ) {
+                                                       /* lookup if mapped -- linear search,
+                                                        * not very efficient unless list
+                                                        * is very short */
+                                                       for ( dlm = dli->dli_dlm; dlm; dlm = dlm->dlm_next ) {
+                                                               if ( dlm->dlm_member_ad == o.ors_attrs[j].an_desc ) {
+                                                                       break;
+                                                               }
+                                                       }
+
+                                                       if ( dlm == NULL ) {
+                                                               continue;
+                                                       }
+                                               }
+
                                        } else {
                                                if ( !userattrs && 
                                                                o.ors_attrs[j].an_desc != NULL &&
                                                                !ad_inlist( o.ors_attrs[j].an_desc, rs->sr_attrs ) )
                                                {
-                                                       continue;
+                                                       /* lookup if mapped -- linear search,
+                                                        * not very efficient unless list
+                                                        * is very short */
+                                                       for ( dlm = dli->dli_dlm; dlm; dlm = dlm->dlm_next ) {
+                                                               if ( dlm->dlm_member_ad == o.ors_attrs[j].an_desc ) {
+                                                                       break;
+                                                               }
+                                                       }
+
+                                                       if ( dlm == NULL ) {
+                                                               continue;
+                                                       }
                                                }
                                        }
                                }