diff options
| author | Nalin Dahyabhai <nalin@redhat.com> | 2010-11-22 15:04:40 -0500 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin@redhat.com> | 2010-11-22 15:04:40 -0500 |
| commit | 760a6e9b7243834bfa30d6b2ac04fabf5d99cb65 (patch) | |
| tree | 9bc96caec673f8bd7ef0ca4ba4f445ec3a522018 /src | |
| parent | e5d73bacd1db958ffe62f8d3a09d085929d0cbdc (diff) | |
- use the filter at the right point in walking a chain
- add a test for deref_rf
Diffstat (limited to 'src')
| -rw-r--r-- | src/format.c | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/format.c b/src/format.c index 4e0b2c9..c7681c3 100644 --- a/src/format.c +++ b/src/format.c @@ -181,6 +181,34 @@ format_add_sdn_list(struct slapi_dn ***list, const char *dn) return *list; } +static int +format_check_entry(const char *dn, char *filter, void *identity) +{ + Slapi_DN *sdn; + Slapi_Entry *entry; + sdn = slapi_sdn_new_dn_byval(dn); + entry = NULL; + wrap_search_internal_get_entry(sdn, filter, NULL, &entry, identity); + slapi_sdn_free(&sdn); + if (entry != NULL) { + slapi_entry_free(entry); + return 0; + } else { + return ENOENT; + } +} + +static struct slapi_dn ** +format_add_filtered_sdn_list(struct slapi_dn ***list, const char *dn, + char *filter, void *identity) +{ + if (format_check_entry(dn, filter, identity) == 0) { + return format_add_sdn_list(list, dn); + } else { + return *list; + } +} + /* Maintain a reference attribute list, which is group of lists of attribute * names, filters, and search bases. */ void @@ -1056,7 +1084,7 @@ format_deref_rx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, /* Pull up the named entry. */ entry = NULL; wrap_search_internal_get_entry(these[j], - list->links[i].filter_str, + NULL, attrs, &entry, state->plugin_identity); if (entry == NULL) { @@ -1099,10 +1127,16 @@ format_deref_rx(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e, } /* Let's visit the named entry this * time, in case we're nesting. */ - format_add_sdn_list(&these, cvalue); + format_add_filtered_sdn_list(&these, + cvalue, + list->links[i + 1].filter_str, + state->plugin_identity); /* We need to visit the named entry * next time. */ - format_add_sdn_list(&next, cvalue); + format_add_filtered_sdn_list(&next, + cvalue, + list->links[i + 1].filter_str, + state->plugin_identity); } else { /* Get the value. */ bval = slapi_value_get_berval(value); |
