ldap_id_services.c revision 4fcc50e133f90cd4c5931a3ac48c84cb628b16fc
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen Stephen Gallagher <sgallagh@redhat.com>
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen Copyright (C) 2012 Red Hat
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen This program is free software; you can redistribute it and/or modify
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen it under the terms of the GNU General Public License as published by
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen the Free Software Foundation; either version 3 of the License, or
51dbc2d559815da774f8ee5faf0e28df3c8d40c0Timo Sirainen (at your option) any later version.
51dbc2d559815da774f8ee5faf0e28df3c8d40c0Timo Sirainen This program is distributed in the hope that it will be useful,
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen GNU General Public License for more details.
54a8bb6e9b852d9a96a8cdda1bb55a85ce0e10daTimo Sirainen You should have received a copy of the GNU General Public License
6b0e35b29f65a95fe8ae22ed8b5f0f36720c9f45Timo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen const char **attrs;
9c0cd052c03799d764938ffe500cf510bf9eb464Timo Sirainenservices_get_connect_done(struct tevent_req *subreq);
d23c747de9d33966483fbdd41f08ad7766da7c5cTimo Sirainen req = tevent_req_create(mem_ctx, &state, struct sdap_services_get_state);
eca38954bcf972618f6b85932a3690acbd2b673aTimo Sirainen state->op = sdap_id_op_create(state, state->conn->conn_cache);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen DEBUG(SSSDBG_MINOR_FAILURE, ("sdap_id_op_create failed\n"));
54a8bb6e9b852d9a96a8cdda1bb55a85ce0e10daTimo Sirainen attr_name = id_ctx->opts->service_map[SDAP_AT_SERVICE_NAME].name;
3ccfcf0856958cb9208a9fc51c3bdf13c58ad52aTimo Sirainen attr_name = id_ctx->opts->service_map[SDAP_AT_SERVICE_PORT].name;
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen ret = sss_filter_sanitize(state, name, &clean_name);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen ret = sss_filter_sanitize(state, protocol, &clean_protocol);
62300a38f91227b9de043a9a8ec1d4f1978e1138Timo Sirainen id_ctx->opts->service_map[SDAP_AT_SERVICE_PROTOCOL].name,
62300a38f91227b9de043a9a8ec1d4f1978e1138Timo Sirainen id_ctx->opts->service_map[SDAP_OC_SERVICE].name);
62300a38f91227b9de043a9a8ec1d4f1978e1138Timo Sirainen talloc_asprintf(state, "(&(%s=%s)(objectclass=%s))",
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen id_ctx->opts->service_map[SDAP_OC_SERVICE].name);
6b0e35b29f65a95fe8ae22ed8b5f0f36720c9f45Timo Sirainen ("Failed to build the base filter\n"));
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen ("Preparing to search for services with filter [%s]\n",
02d91785bcf42ced46080db91c29bb534fbe2d1cTimo Sirainen ret = build_attrs_from_map(state, id_ctx->opts->service_map,
b5052fbfdbc2678cc8f12899afe55c998f43b740Timo Sirainen tevent_req_data(req, struct sdap_services_get_state);
b5052fbfdbc2678cc8f12899afe55c998f43b740Timo Sirainen subreq = sdap_id_op_connect_send(state->op, state, &ret);
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen tevent_req_set_callback(subreq, services_get_connect_done, req);
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainenservices_get_connect_done(struct tevent_req *subreq)
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen tevent_req_callback_data(subreq, struct tevent_req);
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen tevent_req_data(req, struct sdap_services_get_state);
eddd9bf1a1369aea4a2715f6be1137da6d17d293Timo Sirainen ret = sdap_id_op_connect_recv(subreq, &dp_error);
54a8bb6e9b852d9a96a8cdda1bb55a85ce0e10daTimo Sirainen subreq = sdap_get_services_send(state, state->ev,
661998e2ccd772ad92a9d4a75cb712692a8c94b3Timo Sirainen tevent_req_set_callback(subreq, services_get_done, req);
1795e934ebcd58175d3b5bbdd811b13c7889efa3Timo Sirainen tevent_req_callback_data(subreq, struct tevent_req);
51dbc2d559815da774f8ee5faf0e28df3c8d40c0Timo Sirainen tevent_req_data(req, struct sdap_services_get_state);
39dea5f2e78f6bfc3adc0655176f596ee211938fTimo Sirainen ret = sdap_get_services_recv(NULL, subreq, NULL);
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainen /* Check whether we need to try again with another
02d91785bcf42ced46080db91c29bb534fbe2d1cTimo Sirainen * failover server.
bd7b1a9000b12349e2a99bb43b3ce8b96a18e92bTimo Sirainen ret = sdap_id_op_done(state->op, ret, &dp_error);
02d91785bcf42ced46080db91c29bb534fbe2d1cTimo Sirainen /* Return to the mainloop to retry */
048e40f9364fa68482bc276dd4a5d595a3d742e9Timo Sirainen /* An error occurred. */
c4478af52de63804efef2055580adf1dfc8679c6Timo Sirainen if (ret == ENOENT && state->noexist_delete == true) {
54a8bb6e9b852d9a96a8cdda1bb55a85ce0e10daTimo Sirainen /* Ensure that this entry is removed from the sysdb */
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen ret = sysdb_svc_delete(state->domain, state->name,
82995cc154a929f37aa486a72a6485e9f8d34a30Timo Sirainen ret = sysdb_svc_delete(state->domain, NULL, port,
if (dp_error_out) {
if (sdap_ret) {
return EOK;