>From 2463d66d1cd84d3abb48ac5bb2780dc619ea699d Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Wed, 24 Nov 2010 14:17:36 +0100 Subject: [PATCH 3/3] Add check_online method to LDAP ID provider --- src/providers/ipa/ipa_init.c | 3 +- src/providers/ldap/ldap_common.h | 1 + src/providers/ldap/ldap_id.c | 41 ++++++++++++++++++++++++++++++++++++++ src/providers/ldap/ldap_init.c | 3 +- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/providers/ipa/ipa_init.c b/src/providers/ipa/ipa_init.c index 2a63ac8..f6769ee 100644 --- a/src/providers/ipa/ipa_init.c +++ b/src/providers/ipa/ipa_init.c @@ -40,7 +40,8 @@ struct ipa_options *ipa_options = NULL; /* Id Handler */ struct bet_ops ipa_id_ops = { .handler = sdap_account_info_handler, - .finalize = NULL + .finalize = NULL, + .check_online = sdap_check_online }; struct bet_ops ipa_auth_ops = { diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h index 63192fb..5c298d1 100644 --- a/src/providers/ldap/ldap_common.h +++ b/src/providers/ldap/ldap_common.h @@ -67,6 +67,7 @@ struct sdap_auth_ctx { struct sdap_service *service; }; +void sdap_check_online(struct be_req *breq); /* id */ void sdap_account_info_handler(struct be_req *breq); int sdap_id_setup_tasks(struct sdap_id_ctx *ctx); diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c index 07e3ae1..1a9b2e0 100644 --- a/src/providers/ldap/ldap_id.c +++ b/src/providers/ldap/ldap_id.c @@ -650,7 +650,48 @@ int groups_by_user_recv(struct tevent_req *req, int *dp_error_out) return EOK; } +static void sdap_check_online_done(struct tevent_req *req); +void sdap_check_online(struct be_req *be_req) +{ + struct sdap_id_ctx *ctx; + struct tevent_req *req; + + ctx = talloc_get_type(be_req->be_ctx->bet_info[BET_ID].pvt_bet_data, + struct sdap_id_ctx); + + req = sdap_cli_connect_send(be_req, be_req->be_ctx->ev, ctx->opts, + be_req->be_ctx, ctx->service, false); + if (req == NULL) { + DEBUG(1, ("sdap_cli_connect_send failed.\n")); + goto done; + } + tevent_req_set_callback(req, sdap_check_online_done, be_req); + + return; +done: + sdap_handler_done(be_req, DP_ERR_FATAL, 0, NULL); +} +static void sdap_check_online_done(struct tevent_req *req) +{ + struct be_req *be_req = tevent_req_callback_data(req, struct be_req); + int ret; + int dp_err = DP_ERR_FATAL; + bool can_retry; + + ret = sdap_cli_connect_recv_ext(req, NULL, &can_retry, NULL); + talloc_zfree(req); + + if (ret != EOK) { + if (!can_retry) { + dp_err = DP_ERR_OFFLINE; + } + } else { + dp_err = DP_ERR_OK; + } + + sdap_handler_done(be_req, dp_err, 0, NULL); +} /* =Get-Account-Info-Call================================================= */ diff --git a/src/providers/ldap/ldap_init.c b/src/providers/ldap/ldap_init.c index dcfb553..b6176a9 100644 --- a/src/providers/ldap/ldap_init.c +++ b/src/providers/ldap/ldap_init.c @@ -32,7 +32,8 @@ static void sdap_shutdown(struct be_req *req); /* Id Handler */ struct bet_ops sdap_id_ops = { .handler = sdap_account_info_handler, - .finalize = sdap_shutdown + .finalize = sdap_shutdown, + .check_online = sdap_check_online }; /* Auth Handler */ -- 1.7.3.2