summaryrefslogtreecommitdiffstats
path: root/src/back-sch.c
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-07-15 11:51:12 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-07-15 11:51:12 -0400
commit2a9da7abdb4866d569ac5ebb912e63d968f27f09 (patch)
treeeeb3817b2d762212cedb6421f86d8bde6cc2f993 /src/back-sch.c
parentecdc1eae6e72d0e4553666d632d1181056be5123 (diff)
downloadslapi-nis-2a9da7abdb4866d569ac5ebb912e63d968f27f09.tar.gz
slapi-nis-2a9da7abdb4866d569ac5ebb912e63d968f27f09.tar.xz
slapi-nis-2a9da7abdb4866d569ac5ebb912e63d968f27f09.zip
- use an internal function to send search results back in the expected manner
Diffstat (limited to 'src/back-sch.c')
-rw-r--r--src/back-sch.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/back-sch.c b/src/back-sch.c
index ebd92c0..5a3fffa 100644
--- a/src/back-sch.c
+++ b/src/back-sch.c
@@ -763,6 +763,8 @@ backend_search_cb(Slapi_PBlock *pb)
cbdata.closest_match = NULL;
cbdata.text = NULL;
cbdata.n_entries = 0;
+ /* If we were called to service one of our internal searches, stop
+ * right here. */
if (backend_shr_is_caller(cbdata.state, cbdata.pb)) {
slapi_log_error(SLAPI_LOG_PLUGIN,
cbdata.state->plugin_desc->spd_id,
@@ -771,12 +773,16 @@ backend_search_cb(Slapi_PBlock *pb)
cbdata.target, cbdata.strfilter, cbdata.scope);
return 0;
}
+ /* Okay, we can search. */
slapi_log_error(SLAPI_LOG_PLUGIN, cbdata.state->plugin_desc->spd_id,
"searching from \"%s\" for \"%s\" with scope %d\n",
cbdata.target, cbdata.strfilter, cbdata.scope);
cbdata.target_dn = slapi_sdn_new_dn_byval(cbdata.target);
+ /* Walk the list of groups. */
map_rdlock();
map_data_foreach_domain(cbdata.state, backend_search_group_cb, &cbdata);
+ map_unlock();
+ /* If we "own" the search target DN, then we need to send a response. */
if (cbdata.answer) {
if (cbdata.matched || (cbdata.n_entries > 0)) {
/* Just in case, free the closest-match that we've
@@ -796,15 +802,24 @@ backend_search_cb(Slapi_PBlock *pb)
cbdata.closest_match ?
cbdata.closest_match : "(null)",
cbdata.closest_match ? "\"" : "");
- slapi_send_ldap_result(cbdata.pb, cbdata.result,
- cbdata.closest_match, cbdata.text,
- cbdata.n_entries, NULL);
+ slapi_pblock_set(cbdata.pb, SLAPI_PLUGIN_OPRETURN,
+ &cbdata.result);
+ /* XXX - THIS IS NOT A PUBLIC FUNCTION, but
+ * slapi_send_ldap_result() stores the values we pass in, calls
+ * the backend functions, which then overwrite the matched-dn
+ * with a "real" entry's name before sending back the result.
+ * If we return a -1 here, we prevent backends from being
+ * called, but then no result gets sent if we use
+ * slapi_send_ldap_result(), so we call the internal
+ * send_ldap_result() function directly. */
+ send_ldap_result(cbdata.pb, cbdata.result,
+ cbdata.closest_match, cbdata.text,
+ cbdata.n_entries, NULL);
}
- map_unlock();
slapi_sdn_free(&cbdata.target_dn);
free(cbdata.closest_match);
free(cbdata.text);
- return 0;
+ return cbdata.answer ? -1 : 0;
}
/* Locate the entry for a given DN. */