2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom/*
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom SSSD
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom LDAP ID backend operation retry logic and connection cache
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom Authors:
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom Eugene Indenbom <eindenbom@gmail.com>
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom Copyright (C) 2008-2010 Red Hat
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom This program is free software; you can redistribute it and/or modify
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom it under the terms of the GNU General Public License as published by
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom the Free Software Foundation; either version 3 of the License, or
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom (at your option) any later version.
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom This program is distributed in the hope that it will be useful,
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom but WITHOUT ANY WARRANTY; without even the implied warranty of
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom GNU General Public License for more details.
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom You should have received a copy of the GNU General Public License
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom along with this program. If not, see <http://www.gnu.org/licenses/>.
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom*/
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom#ifndef _SDAP_ID_OP_H_
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom#define _SDAP_ID_OP_H_
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
cf1cf7b96d38c8b481a90d800cf53546ac15ce8aSimo Sorcestruct sdap_id_ctx;
dcb44c39dda9699cdd6488fd116a51ced0687de3Jakub Hrozekstruct sdap_id_conn_ctx;
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom/* LDAP async connection cache */
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbomstruct sdap_id_conn_cache;
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom/* LDAP async operation tracker:
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * - keeps track of connection usage
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * - keeps track of operation retries */
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbomstruct sdap_id_op;
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom/* Create a connection cache */
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbomint sdap_id_conn_cache_create(TALLOC_CTX *memctx,
dcb44c39dda9699cdd6488fd116a51ced0687de3Jakub Hrozek struct sdap_id_conn_ctx *id_conn,
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom struct sdap_id_conn_cache** conn_cache_out);
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom/* Create an operation object */
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbomstruct sdap_id_op *sdap_id_op_create(TALLOC_CTX *memctx, struct sdap_id_conn_cache *cache);
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom/* Begin to connect to LDAP server. */
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbomstruct tevent_req *sdap_id_op_connect_send(struct sdap_id_op *op,
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom TALLOC_CTX *memctx,
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom int *ret_out);
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom/* Get the result of an asynchronous connect operation on sdap_id_op
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom *
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * In dp_error data provider error code is returned:
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * DP_ERR_OK - connection established
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * DP_ERR_OFFLINE - backend is offline, operation result is set EAGAIN
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * DP_ERR_FATAL - operation failed
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom */
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbomint sdap_id_op_connect_recv(struct tevent_req *req, int *dp_error);
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom/* Report completion of LDAP operation and release associated connection.
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * Returns operation result (possible updated) passed in ret parameter.
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom *
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * In dp_error data provider error code is returned:
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * DP_ERR_OK (operation result = EOK) - operation completed
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * DP_ERR_OK (operation result != EOK) - operation can be retried
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * DP_ERR_OFFLINE - backend is offline, operation result is set EAGAIN
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom * DP_ERR_FATAL - operation failed */
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbomint sdap_id_op_done(struct sdap_id_op*, int ret, int *dp_error);
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom/* Get SDAP handle associated with operation by sdap_id_op_connect */
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbomstruct sdap_handle *sdap_id_op_handle(struct sdap_id_op *op);
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom/* Get root DSE entry of connected LDAP server */
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbomconst struct sysdb_attrs *sdap_id_op_rootDSE(struct sdap_id_op *op);
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom
2d7a7b0140a4d3fcef9148900276e24f82e33866eindenbom#endif /* _SDAP_ID_OP_H_ */