db-ldap.c revision c4457e497e01b57565d24da624968699b166e02a
/* Copyright (C) 2003 Timo Sirainen */
#include "config.h"
#if defined(PASSDB_LDAP) || defined(USERDB_LDAP)
#include "common.h"
#include "network.h"
#include "ioloop.h"
#include "hash.h"
#include "settings.h"
#include "db-ldap.h"
#include <stddef.h>
/* This may block the process for two seconds, but at least it works. */
#if LDAP_VENDOR_VERSION <= 20026
# define OPENLDAP_ASYNC_WORKAROUND
#endif
static struct setting_def setting_defs[] = {
};
struct ldap_settings default_ldap_settings = {
};
{
return LDAP_DEREF_NEVER;
return LDAP_DEREF_SEARCHING;
return LDAP_DEREF_FINDING;
return LDAP_DEREF_ALWAYS;
}
{
return LDAP_SCOPE_BASE;
return LDAP_SCOPE_ONELEVEL;
return LDAP_SCOPE_SUBTREE;
}
{
if (ret != LDAP_SUCCESS) {
i_error("LDAP: Can't get error number: %s",
return "??";
}
return ldap_err2string(err);
}
const char *filter, char **attributes,
struct ldap_request *request)
{
int msgid;
if (!ldap_conn_open(conn)) {
return;
}
}
if (msgid == -1) {
i_error("LDAP: ldap_search() failed (filter %s): %s",
return;
}
}
static void ldap_input(void *context)
{
struct ldap_request *request;
for (;;) {
#ifdef OPENLDAP_ASYNC_WORKAROUND
/* we may block, but at least we work */
#endif
if (ret <= 0) {
if (ret < 0) {
i_error("LDAP: ldap_result() failed: %s",
}
return;
}
if (ret != LDAP_SUCCESS) {
i_error("LDAP: ldap_result() failed: %s",
} else {
} else {
i_error("LDAP: Reply with unknown msgid %d",
msgid);
}
}
}
}
{
return TRUE;
i_fatal("LDAP: ldap_init() failed with hosts: %s",
if (ret != LDAP_SUCCESS) {
i_fatal("LDAP: Can't set deref option: %s",
}
}
/* NOTE: we use blocking connect, we couldn't do anything anyway
until it's done. */
if (ret != LDAP_SUCCESS) {
i_error("LDAP: ldap_simple_bind_s() failed: %s",
return FALSE;
}
/* register LDAP input to ioloop */
if (ret != LDAP_SUCCESS) {
i_fatal("LDAP: Can't get connection fd: %s",
}
return TRUE;
}
{
}
}
}
unsigned int **attrs, char ***attr_names)
{
const char *const *attr;
i_fatal("Missing uid field in attrs");
/* +1 for terminating NULL */
if (**attr != '\0') {
dest++;
}
}
}
void *context)
{
}
{
struct ldap_connection *conn;
return conn;
}
return NULL;
}
{
struct ldap_connection *conn;
/* see if it already exists */
return conn;
}
i_fatal("LDAP: No base given");
(void)ldap_conn_open(conn);
return conn;
}
{
return;
}
#endif