diff options
author | Simo Sorce <ssorce@redhat.com> | 2010-02-28 01:44:42 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-04-12 09:22:12 -0400 |
commit | 1c733ece101ca43b84c59a8dc7953346312dbf64 (patch) | |
tree | 672ba8c8fed42fefe8a4f3fa67a8ff38397e874a /src/providers/ipa | |
parent | 0995e4cc173577122bea5a1d4698262fd0e9c200 (diff) | |
download | sssd_unused-1c733ece101ca43b84c59a8dc7953346312dbf64.tar.gz sssd_unused-1c733ece101ca43b84c59a8dc7953346312dbf64.tar.xz sssd_unused-1c733ece101ca43b84c59a8dc7953346312dbf64.zip |
sysdb: convert sysdb_search_user_by_name/uid
Diffstat (limited to 'src/providers/ipa')
-rw-r--r-- | src/providers/ipa/ipa_access.c | 75 |
1 files changed, 14 insertions, 61 deletions
diff --git a/src/providers/ipa/ipa_access.c b/src/providers/ipa/ipa_access.c index 5cf9bf49..1ea77b20 100644 --- a/src/providers/ipa/ipa_access.c +++ b/src/providers/ipa/ipa_access.c @@ -110,7 +110,6 @@ struct hbac_get_user_info_state { const char **groups; }; -static void search_user_done(struct tevent_req *subreq); static void search_groups_done(struct tevent_req *subreq); struct tevent_req *hbac_get_user_info_send(TALLOC_CTX *memctx, @@ -122,7 +121,9 @@ struct tevent_req *hbac_get_user_info_send(TALLOC_CTX *memctx, struct tevent_req *subreq = NULL; struct hbac_get_user_info_state *state; int ret; - const char **attrs; + static const char *attrs[] = { SYSDB_ORIG_DN, NULL }; + struct ldb_message *user_msg; + const char *dummy; req = tevent_req_create(memctx, &state, struct hbac_get_user_info_state); if (req == NULL) { @@ -139,50 +140,10 @@ struct tevent_req *hbac_get_user_info_send(TALLOC_CTX *memctx, state->groups_count = 0; state->groups = NULL; - attrs = talloc_array(state, const char *, 2); - if (attrs == NULL) { - ret = ENOMEM; - goto fail; - } - - attrs[0] = SYSDB_ORIG_DN; - attrs[1] = NULL; - - subreq = sysdb_search_user_by_name_send(state, ev, be_ctx->sysdb, NULL, - be_ctx->domain, user, attrs); - if (subreq == NULL) { - DEBUG(1, ("sysdb_search_user_by_name_send failed.\n")); - ret = ENOMEM; - goto fail; - } - - tevent_req_set_callback(subreq, search_user_done, req); - - return req; - -fail: - tevent_req_error(req, ret); - tevent_req_post(req, ev); - return req; -} - -static void search_user_done(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data(subreq, - struct tevent_req); - struct hbac_get_user_info_state *state = tevent_req_data(req, - struct hbac_get_user_info_state); - int ret; - const char **attrs; - const char *dummy; - struct ldb_message *user_msg; - - - ret = sysdb_search_user_recv(subreq, state, &user_msg); - talloc_zfree(subreq); + ret = sysdb_search_user_by_name(state, be_ctx->sysdb, + be_ctx->domain, user, attrs, &user_msg); if (ret != EOK) { - tevent_req_error(req, ret); - return; + goto fail; } DEBUG(9, ("Found user info for user [%s].\n", state->user)); @@ -191,41 +152,33 @@ static void search_user_done(struct tevent_req *subreq) if (dummy == NULL) { DEBUG(1, ("Original DN of user [%s] not available.\n", state->user)); ret = EINVAL; - goto failed; + goto fail; } state->user_orig_dn = talloc_strdup(state, dummy); if (state->user_dn == NULL) { DEBUG(1, ("talloc_strdup failed.\n")); ret = ENOMEM; - goto failed; + goto fail; } DEBUG(9, ("Found original DN [%s] for user [%s].\n", state->user_orig_dn, state->user)); - attrs = talloc_array(state, const char *, 2); - if (attrs == NULL) { - DEBUG(1, ("talloc_array failed.\n")); - ret = ENOMEM; - goto failed; - } - attrs[0] = SYSDB_ORIG_DN; - attrs[1] = NULL; - subreq = sysdb_asq_search_send(state, state->ev, state->be_ctx->sysdb, NULL, state->be_ctx->domain, state->user_dn, NULL, SYSDB_MEMBEROF, attrs); if (subreq == NULL) { DEBUG(1, ("sysdb_asq_search_send failed.\n")); ret = ENOMEM; - goto failed; + goto fail; } - tevent_req_set_callback(subreq, search_groups_done, req); - return; -failed: + return req; + +fail: tevent_req_error(req, ret); - return; + tevent_req_post(req, ev); + return req; } static void search_groups_done(struct tevent_req *subreq) |