--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/server/safs/ldap.h Sat Mar 11 17:14:51 2023 +0100 @@ -0,0 +1,80 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2023 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WS_SAFS_LDAP_H +#define WS_SAFS_LDAP_H + +#include "../public/nsapi.h" + +#include "../daemon/ldap_resource.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define WS_SAFS_LDAP_DEFAULT_SCOPE LDAP_SCOPE_SUBTREE +#define WS_SAFS_LDAP_DEFAULT_TIMEOUT 30 +#define WS_SAFS_LDAP_DEFAULT_SIZELIMIT 1000 + +#define WS_SAFS_LDAP_MAX_TIMEOUT 32767 + +#define WS_SAFS_LDAP_EMPTY_QUERY_ERROR 404 +#define WS_SAFS_LDAP_EMPTY_RESULT_ERROR 404 + +/* + * ldap-query + * + * Sends an ldap query result as ldif to the client. If no query parameter is + * specified, the SAFs tries to use the "ldap_query" parameter from rq->vars. + * + * required parameters: + * resource name of the ldap resource pool + * basedn ldap basedn + * + * optional parameters: + * binddn bind ldap session to binddn + * bindpw binddn password + * query ldap search query + * scope search scope: base, onelevel, subtree, children + * timeout timeout in seconds default: 30 + * sizelimit maximum number of result entries defazkt: 1000 + * empty_query_error status code if the query is empty/null default: 404 + * empty_result_error status code if the result is empty default: 404 + * + * If the query or result is empty and the status code is 2xx, an empty + * response is sent to the client. + */ +int ldap_query_saf(pblock *pb, Session *sn, Request *rq); + + +#ifdef __cplusplus +} +#endif + +#endif /* WS_SAFS_LDAP_H */ +