summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-03-14 17:27:05 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-04-12 09:22:15 -0400
commit7ffaa2afb9e03a6f0b9c602c0f03b2074ea33eac (patch)
treeabc9f4bfcc276834c922463120b35c66ee3bd033 /src/db
parent0a7a138cd47dcff3f4d53da2db4fa155708b8aeb (diff)
downloadsssd-7ffaa2afb9e03a6f0b9c602c0f03b2074ea33eac.tar.gz
sssd-7ffaa2afb9e03a6f0b9c602c0f03b2074ea33eac.tar.xz
sssd-7ffaa2afb9e03a6f0b9c602c0f03b2074ea33eac.zip
sysdb: convert sysdb_getpwnam
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h2
-rw-r--r--src/db/sysdb_search.c38
2 files changed, 22 insertions, 18 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 7da98fa84..365e6adf6 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -253,7 +253,7 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
struct sss_domain_info *domain,
const char *name,
- sysdb_callback_t fn, void *ptr);
+ struct ldb_result **res);
int sysdb_getpwuid(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
index 4b9470baa..2403917b7 100644
--- a/src/db/sysdb_search.c
+++ b/src/db/sysdb_search.c
@@ -215,38 +215,42 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
struct sss_domain_info *domain,
const char *name,
- sysdb_callback_t fn, void *ptr)
+ struct ldb_result **_res)
{
+ TALLOC_CTX *tmpctx;
static const char *attrs[] = SYSDB_PW_ATTRS;
- struct sysdb_search_ctx *sctx;
- struct tevent_req *req;
+ struct ldb_dn *base_dn;
+ struct ldb_result *res;
+ int ret;
if (!domain) {
return EINVAL;
}
- sctx = init_src_ctx(mem_ctx, domain, ctx, fn, ptr);
- if (!sctx) {
+ tmpctx = talloc_new(mem_ctx);
+ if (!tmpctx) {
return ENOMEM;
}
- sctx->expression = talloc_asprintf(sctx, SYSDB_PWNAM_FILTER, name);
- if (!sctx->expression) {
- talloc_free(sctx);
- return ENOMEM;
+ base_dn = ldb_dn_new_fmt(tmpctx, ctx->ldb,
+ SYSDB_TMPL_USER_BASE, domain->name);
+ if (!base_dn) {
+ ret = ENOMEM;
+ goto done;
}
- sctx->attrs = attrs;
-
- req = sysdb_operation_send(mem_ctx, ctx->ev, ctx);
- if (!req) {
- talloc_free(sctx);
- return ENOMEM;
+ ret = ldb_search(ctx->ldb, tmpctx, &res, base_dn,
+ LDB_SCOPE_SUBTREE, attrs, SYSDB_PWNAM_FILTER, name);
+ if (ret) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
}
- tevent_req_set_callback(req, user_search, sctx);
+ *_res = talloc_steal(mem_ctx, res);
- return EOK;
+done:
+ talloc_zfree(tmpctx);
+ return ret;
}
int sysdb_getpwuid(TALLOC_CTX *mem_ctx,