summaryrefslogtreecommitdiffstats
path: root/src/db/sysdb_search.c
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-03-20 17:38:30 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-04-12 09:22:16 -0400
commit08d9d10747da6900971cdd8fced05ca66f5111e2 (patch)
tree00052037e1279b115b143adb532c0a506472f1c7 /src/db/sysdb_search.c
parentac660a221255b761615f6ecdb63b92a6391a58a2 (diff)
downloadsssd-08d9d10747da6900971cdd8fced05ca66f5111e2.tar.gz
sssd-08d9d10747da6900971cdd8fced05ca66f5111e2.tar.xz
sssd-08d9d10747da6900971cdd8fced05ca66f5111e2.zip
sysdb: convert sysdb_get_user_attr
Diffstat (limited to 'src/db/sysdb_search.c')
-rw-r--r--src/db/sysdb_search.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
index cabf19f45..8d8a0e11a 100644
--- a/src/db/sysdb_search.c
+++ b/src/db/sysdb_search.c
@@ -706,35 +706,40 @@ int sysdb_get_user_attr(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
const char *name,
const char **attributes,
- sysdb_callback_t fn, void *ptr)
+ struct ldb_result **_res)
{
- struct sysdb_search_ctx *sctx;
- struct tevent_req *req;
+ TALLOC_CTX *tmpctx;
+ 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 = attributes;
-
- 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, attributes,
+ 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;
}