sss_ldap.c revision 23d17a0389386c09b72dba31bac5f586c904f113
/*
Authors:
Sumit Bose <sbose@redhat.com>
Copyright (C) 2009 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "config.h"
#include "util/sss_ldap.h"
const char* sss_ldap_err2string(int err)
{
static const char *password_expired = "Password expired";
switch (err) {
return password_expired;
default:
return ldap_err2string(err);
}
}
{
int optret;
if (optret != LDAP_SUCCESS) {
return EINVAL;
}
return ENOMEM;
}
return EOK;
}
LDAPControl **ctrlp)
{
#ifdef HAVE_LDAP_CONTROL_CREATE
#else
return LDAP_PARAM_ERROR;
}
return LDAP_NO_MEMORY;
}
return LDAP_NO_MEMORY;
}
if (dupval == 0) {
} else {
return LDAP_NO_MEMORY;
}
}
}
return LDAP_SUCCESS;
#endif
}
#ifdef HAVE_LDAP_INIT_FD
struct sdap_async_sys_connect_state {
long old_flags;
int fd;
struct sockaddr_storage addr;
};
void *priv);
struct tevent_context *ev,
int fd,
{
struct tevent_req *req;
struct sdap_async_sys_connect_state *state;
long flags;
int ret;
int fret;
if (flags == -1) {
return NULL;
}
struct sdap_async_sys_connect_state);
return NULL;
}
goto done;
}
goto done;
}
switch(ret) {
case EINPROGRESS:
case EINTR:
goto done;
}
return req;
break;
default:
}
done:
}
} else {
}
return req;
}
void *priv)
{
struct sdap_async_sys_connect_state);
int ret;
int fret;
errno = 0;
return; /* Try again later */
}
}
}
} else {
}
return;
}
{
return EOK;
}
{
int ret;
long flags;
int dummy = 1;
if (flags == -1) {
return ret;
}
if (flags == -1) {
return ret;
}
/* SO_KEEPALIVE and TCP_NODELAY are set by OpenLDAP client libraries but
* failures are ignored.*/
if (ret != 0) {
}
if (ret != 0) {
}
return EOK;
}
struct tevent_timer *te,
#endif
struct sss_ldap_init_state {
int sd;
const char *uri;
#ifdef HAVE_LDAP_INIT_FD
struct tevent_timer *connect_timeout;
#endif
};
struct tevent_context *ev,
const char *uri,
struct sockaddr_storage *addr,
{
struct tevent_req *req;
struct sss_ldap_init_state *state;
return NULL;
}
#ifdef HAVE_LDAP_INIT_FD
struct tevent_req *subreq;
goto fail;
}
goto fail;
}
goto fail;
}
subreq);
goto fail;
}
return req;
fail:
}
#else
"will use ldap_initialize with uri [%s].\n", uri));
if (ret == LDAP_SUCCESS) {
} else {
if (ret == LDAP_SERVER_DOWN) {
} else {
}
}
#endif
return req;
}
#ifdef HAVE_LDAP_INIT_FD
struct tevent_timer *te,
{
struct tevent_req *connection_request;
}
{
struct tevent_req);
struct sss_ldap_init_state);
int ret;
int lret;
return;
}
/* Initialize LDAP handler */
if (lret != LDAP_SUCCESS) {
if (lret == LDAP_SERVER_DOWN) {
} else {
}
return;
}
if (lret != LDAP_SUCCESS) {
if (lret == LDAP_LOCAL_ERROR) {
} else {
return;
}
}
}
return;
}
#endif
{
struct sss_ldap_init_state);
return EOK;
}
/*
* _filter will contain combined filters from all possible search bases
* or NULL if it should be empty
*/
const char *dn,
struct sdap_search_base **search_bases,
char **_filter)
{
struct sdap_search_base *base;
int basedn_len, dn_len;
int len_diff;
int i, j;
bool base_confirmed = false;
bool comma_found = false;
bool backslash_found = false;
bool ret = false;
ret = false;
goto done;
}
if (search_bases == NULL) {
ret = false;
goto done;
}
for (i = 0; search_bases[i] != NULL; i++) {
base = search_bases[i];
if (basedn_len > dn_len) {
continue;
}
if (!base_confirmed) {
continue;
}
case LDAP_SCOPE_BASE:
/* dn > base? */
if (len_diff != 0) {
continue;
}
break;
case LDAP_SCOPE_ONELEVEL:
if (len_diff == 0) {
/* Base object doesn't belong to scope=one
* search */
continue;
}
comma_found = false;
if (dn[j] == '\\') {
backslash_found = true;
comma_found = true;
break;
} else {
backslash_found = false;
}
}
/* it has at least one more level */
if (comma_found) {
continue;
}
break;
case LDAP_SCOPE_SUBTREE:
/* dn length >= base dn length && base_confirmed == true */
break;
default:
continue;
}
/*
* If we get here, the dn is valid.
* If no filter is set, than return true immediately.
* Append filter otherwise.
*/
ret = true;
goto done;
} else {
ret = false;
goto done;
}
}
}
ret = false;
goto done;
}
} else {
}
}
done:
return ret;
}