summaryrefslogtreecommitdiffstats
path: root/src/format.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/format.c')
-rw-r--r--src/format.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/format.c b/src/format.c
index 82dac70..8366af9 100644
--- a/src/format.c
+++ b/src/format.c
@@ -712,7 +712,7 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
int i, ret, argc;
Slapi_PBlock *local_pb;
char **argv, *attrs[2], *filter, *tndn;
- char *map_filter, **map_bases;
+ char *set_filter, **set_bases, *use_filter;
struct format_referred_cbdata cbdata;
ret = format_parse_args(state, args, &argc, &argv);
@@ -749,13 +749,10 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
cbdata.ret = 0;
/* Retrieve the map-specific paramters. */
- map_filter = NULL;
- map_bases = NULL;
- backend_get_set_config(state, group, argv[1], &map_bases, &map_filter);
- if (map_filter == NULL) {
- map_filter = "(objectClass=*)";
- }
- if (map_bases == NULL) {
+ set_filter = NULL;
+ set_bases = NULL;
+ backend_get_set_config(state, group, argv[1], &set_bases, &set_filter);
+ if (set_bases == NULL) {
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
"no search bases defined for \"%s\"/\"%s\"?\n",
@@ -772,30 +769,31 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
"referred: out of memory\n");
- backend_free_set_config(map_bases, map_filter);
+ backend_free_set_config(set_bases, set_filter);
slapi_pblock_destroy(local_pb);
format_free_parsed_args(argv);
return -ENOMEM;
}
/* Now just search through the entries used for the map. */
- for (i = 0; (map_bases != NULL) && (map_bases[i] != NULL); i++) {
+ use_filter = set_filter ? set_filter : "(objectClass=*)";
+ for (i = 0; (set_bases != NULL) && (set_bases[i] != NULL); i++) {
/* Build the search filter. */
- filter = malloc(strlen(map_filter) + strlen(argv[2]) +
+ filter = malloc(strlen(use_filter) + strlen(argv[2]) +
strlen(tndn) + 7);
if (filter == NULL) {
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
"referred: out of memory\n");
- backend_free_set_config(map_bases, map_filter);
+ backend_free_set_config(set_bases, set_filter);
slapi_pblock_destroy(local_pb);
format_free_parsed_args(argv);
return -ENOMEM;
}
- sprintf(filter, "(&(%s=%s)%s)", argv[2], tndn, map_filter);
+ sprintf(filter, "(&(%s=%s)%s)", argv[2], tndn, use_filter);
/* Set up the search. */
slapi_search_internal_set_pb(local_pb,
- map_bases[i], LDAP_SCOPE_SUB,
+ set_bases[i], LDAP_SCOPE_SUB,
filter, attrs, FALSE,
NULL, NULL,
state->plugin_identity, 0);
@@ -803,7 +801,7 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
slapi_log_error(SLAPI_LOG_PLUGIN,
state->plugin_desc->spd_id,
"searching under \"%s\" for \"%s\"\n",
- map_bases[i], filter);
+ set_bases[i], filter);
slapi_search_internal_callback_pb(local_pb, &cbdata,
NULL,
format_referred_entry_cb,
@@ -816,7 +814,7 @@ format_referred(struct plugin_state *state, Slapi_PBlock *pb, Slapi_Entry *e,
}
free(tndn);
- backend_free_set_config(map_bases, map_filter);
+ backend_free_set_config(set_bases, set_filter);
slapi_pblock_destroy(local_pb);
format_free_parsed_args(argv);
return cbdata.ret ? cbdata.ret : cbdata.outbuf - outbuf;