summaryrefslogtreecommitdiffstats
path: root/src/providers
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2014-09-16 15:22:08 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-10-16 17:55:49 +0200
commit7d35c7e8c5d2684321be879f7ff67816d4b31f09 (patch)
tree72fd064e188947ebdeadb7e88777ca12853bef44 /src/providers
parent2ef62c64e7f07c8aced3f72850008ecb72860162 (diff)
downloadsssd-7d35c7e8c5d2684321be879f7ff67816d4b31f09.tar.gz
sssd-7d35c7e8c5d2684321be879f7ff67816d4b31f09.tar.xz
sssd-7d35c7e8c5d2684321be879f7ff67816d4b31f09.zip
Add sdap_deref_search_with_filter_send()
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/providers')
-rw-r--r--src/providers/ldap/sdap_async.c76
-rw-r--r--src/providers/ldap/sdap_async.h17
2 files changed, 88 insertions, 5 deletions
diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c
index 8979de466..560d13789 100644
--- a/src/providers/ldap/sdap_async.c
+++ b/src/providers/ldap/sdap_async.c
@@ -1692,9 +1692,10 @@ struct sdap_x_deref_search_state {
static struct tevent_req *
sdap_x_deref_search_send(TALLOC_CTX *memctx, struct tevent_context *ev,
struct sdap_options *opts, struct sdap_handle *sh,
- const char *base_dn, const char *deref_attr,
- const char **attrs, struct sdap_attr_map_info *maps,
- int num_maps, int timeout)
+ const char *base_dn, const char *filter,
+ const char *deref_attr, const char **attrs,
+ struct sdap_attr_map_info *maps, int num_maps,
+ int timeout)
{
struct tevent_req *req = NULL;
struct tevent_req *subreq = NULL;
@@ -1728,7 +1729,9 @@ sdap_x_deref_search_send(TALLOC_CTX *memctx, struct tevent_context *ev,
DEBUG(SSSDBG_TRACE_FUNC,
"Dereferencing entry [%s] using OpenLDAP deref\n", base_dn);
subreq = sdap_get_generic_ext_send(state, ev, opts, sh, base_dn,
- LDAP_SCOPE_BASE, NULL, attrs,
+ filter == NULL ? LDAP_SCOPE_BASE
+ : LDAP_SCOPE_SUBTREE,
+ filter, attrs,
false, state->ctrls, NULL, 0, timeout,
true, sdap_x_deref_parse_entry,
state);
@@ -2532,6 +2535,69 @@ struct sdap_deref_search_state {
};
static void sdap_deref_search_done(struct tevent_req *subreq);
+static void sdap_deref_search_with_filter_done(struct tevent_req *subreq);
+
+struct tevent_req *
+sdap_deref_search_with_filter_send(TALLOC_CTX *memctx,
+ struct tevent_context *ev,
+ struct sdap_options *opts,
+ struct sdap_handle *sh,
+ const char *search_base,
+ const char *filter,
+ const char *deref_attr,
+ const char **attrs,
+ int num_maps,
+ struct sdap_attr_map_info *maps,
+ int timeout)
+{
+ struct tevent_req *req = NULL;
+ struct tevent_req *subreq = NULL;
+ struct sdap_deref_search_state *state;
+
+ req = tevent_req_create(memctx, &state, struct sdap_deref_search_state);
+ if (!req) return NULL;
+
+ state->sh = sh;
+ state->reply_count = 0;
+ state->reply = NULL;
+
+ if (sdap_is_control_supported(sh, LDAP_CONTROL_X_DEREF)) {
+ DEBUG(SSSDBG_TRACE_INTERNAL, "Server supports OpenLDAP deref\n");
+ state->deref_type = SDAP_DEREF_OPENLDAP;
+
+ subreq = sdap_x_deref_search_send(state, ev, opts, sh, search_base,
+ filter, deref_attr, attrs, maps,
+ num_maps, timeout);
+ if (!subreq) {
+ DEBUG(SSSDBG_OP_FAILURE, "Cannot start OpenLDAP deref search\n");
+ goto fail;
+ }
+ } else {
+ DEBUG(SSSDBG_OP_FAILURE,
+ "Server does not support any known deref method!\n");
+ goto fail;
+ }
+
+ tevent_req_set_callback(subreq, sdap_deref_search_with_filter_done, req);
+ return req;
+
+fail:
+ talloc_zfree(req);
+ return NULL;
+}
+
+static void sdap_deref_search_with_filter_done(struct tevent_req *subreq)
+{
+ sdap_deref_search_done(subreq);
+}
+
+int sdap_deref_search_with_filter_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ size_t *reply_count,
+ struct sdap_deref_attrs ***reply)
+{
+ return sdap_deref_search_recv(req, mem_ctx, reply_count, reply);
+}
struct tevent_req *
sdap_deref_search_send(TALLOC_CTX *memctx,
@@ -2571,7 +2637,7 @@ sdap_deref_search_send(TALLOC_CTX *memctx,
DEBUG(SSSDBG_TRACE_INTERNAL, "Server supports OpenLDAP deref\n");
state->deref_type = SDAP_DEREF_OPENLDAP;
- subreq = sdap_x_deref_search_send(state, ev, opts, sh, base_dn,
+ subreq = sdap_x_deref_search_send(state, ev, opts, sh, base_dn, NULL,
deref_attr, attrs, maps, num_maps,
timeout);
if (!subreq) {
diff --git a/src/providers/ldap/sdap_async.h b/src/providers/ldap/sdap_async.h
index 7bb69f2fa..1239f28c1 100644
--- a/src/providers/ldap/sdap_async.h
+++ b/src/providers/ldap/sdap_async.h
@@ -196,6 +196,23 @@ int sdap_get_generic_recv(struct tevent_req *req,
bool sdap_has_deref_support(struct sdap_handle *sh, struct sdap_options *opts);
struct tevent_req *
+sdap_deref_search_with_filter_send(TALLOC_CTX *memctx,
+ struct tevent_context *ev,
+ struct sdap_options *opts,
+ struct sdap_handle *sh,
+ const char *search_base,
+ const char *filter,
+ const char *deref_attr,
+ const char **attrs,
+ int num_maps,
+ struct sdap_attr_map_info *maps,
+ int timeout);
+int sdap_deref_search_with_filter_recv(struct tevent_req *req,
+ TALLOC_CTX *mem_ctx,
+ size_t *reply_count,
+ struct sdap_deref_attrs ***reply);
+
+struct tevent_req *
sdap_deref_search_send(TALLOC_CTX *memctx,
struct tevent_context *ev,
struct sdap_options *opts,