summaryrefslogtreecommitdiffstats
path: root/server/db/sysdb_search.c
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2009-03-02 09:35:06 -0500
committerSimo Sorce <ssorce@redhat.com>2009-03-02 09:47:54 -0500
commit5e3966c99180abdcd1e21774a882f1c14c47aae8 (patch)
tree1a882b9d49f2c7ac25d70f0bbb644b5cefed6439 /server/db/sysdb_search.c
parent6f5b1ad8c234d58041e45aef4558d50f44d7f021 (diff)
downloadsssd-5e3966c99180abdcd1e21774a882f1c14c47aae8.tar.gz
sssd-5e3966c99180abdcd1e21774a882f1c14c47aae8.tar.xz
sssd-5e3966c99180abdcd1e21774a882f1c14c47aae8.zip
Implement GetUserAttributes in the InfoPipe
This patch adds support for requesting user data in the sysdb via the InfoPipe. It currently has support for reading defined entries of integral, floating-point or string types. Tasks remaining: 1) Implement call to the provider when cache is out of date 2) Support byte arrays for userpic and similar I modified sysdb_search_ctx in sysdb_search.c to accept an array of attributes to pass into the LDB search. I also made one additional related fix: the btreemap now sorts in the correct order. Previously I had accidentally transposed the two values for sorting, so the map would always have been in exact reverse order.
Diffstat (limited to 'server/db/sysdb_search.c')
-rw-r--r--server/db/sysdb_search.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/server/db/sysdb_search.c b/server/db/sysdb_search.c
index bb71079b8..b1e63112b 100644
--- a/server/db/sysdb_search.c
+++ b/server/db/sysdb_search.c
@@ -44,6 +44,8 @@ struct sysdb_search_ctx {
struct get_mem_ctx *gmctx;
struct ldb_result *res;
+
+ const char **attrs;
};
static struct sysdb_search_ctx *init_src_ctx(TALLOC_CTX *mem_ctx,
@@ -204,6 +206,37 @@ static void pwd_search(struct sysdb_req *sysreq, void *ptr)
}
}
+static void user_search(struct sysdb_req *sysreq, void *ptr)
+{
+ struct sysdb_search_ctx *sctx;
+ struct ldb_request *req;
+ struct ldb_dn *base_dn;
+ int ret;
+
+ sctx = talloc_get_type(ptr, struct sysdb_search_ctx);
+ sctx->req = sysreq;
+
+ base_dn = ldb_dn_new_fmt(sctx, sctx->ctx->ldb,
+ SYSDB_TMPL_USER_BASE, sctx->domain);
+ if (!base_dn) {
+ return request_error(sctx, ENOMEM);
+ }
+
+ ret = ldb_build_search_req(&req, sctx->ctx->ldb, sctx,
+ base_dn, LDB_SCOPE_SUBTREE,
+ sctx->expression, sctx->attrs, NULL,
+ sctx, get_gen_callback,
+ NULL);
+ if (ret != LDB_SUCCESS) {
+ return request_ldberror(sctx, ret);
+ }
+
+ ret = ldb_request(sctx->ctx->ldb, req);
+ if (ret != LDB_SUCCESS) {
+ return request_ldberror(sctx, ret);
+ }
+}
+
int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
const char *domain,
@@ -729,3 +762,31 @@ int sysdb_initgroups(TALLOC_CTX *mem_ctx,
return sysdb_operation(mem_ctx, ctx, initgr_search, sctx);
}
+int sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *ctx,
+ struct sss_domain_info *domain,
+ const char *name,
+ const char **attributes,
+ sysdb_callback_t fn, void *ptr)
+{
+ struct sysdb_search_ctx *sctx;
+
+ if (!domain) {
+ return EINVAL;
+ }
+
+ sctx = init_src_ctx(mem_ctx, domain->name, domain->legacy, ctx, fn, ptr);
+ if (!sctx) {
+ return ENOMEM;
+ }
+
+ sctx->expression = talloc_asprintf(sctx, SYSDB_PWNAM_FILTER, name);
+ if (!sctx->expression) {
+ talloc_free(sctx);
+ return ENOMEM;
+ }
+
+ sctx->attrs = attributes;
+
+ return sysdb_operation(mem_ctx, ctx, user_search, sctx);
+}