passdb-ldap.c revision 03c3bce84b21b58edf535ba6cc8ee6c8fbadd924
/* Copyright (C) 2003 Timo Sirainen */
#include "common.h"
#ifdef PASSDB_LDAP
#include "hash.h"
#include "str.h"
#include "var-expand.h"
#include "password-scheme.h"
#include "auth-cache.h"
#include "db-ldap.h"
#include "passdb.h"
#include <ldap.h>
#include <stdlib.h>
static const char *default_attr_map[] = {
};
struct ldap_passdb_module {
struct passdb_module module;
struct ldap_connection *conn;
};
struct passdb_ldap_request {
struct ldap_request request;
union {
} callback;
};
struct ldap_query_save_context {
struct ldap_connection *conn;
struct auth_request *auth_request;
unsigned int userdb_fields:1;
unsigned int add_userdb_uid:1;
unsigned int add_userdb_gid:1;
};
static void
{
const char *name;
char **vals;
unsigned int i;
if (auth->verbose_debug) {
else
}
return;
/* in case we're trying to use prefetch userdb,
if (!ctx->userdb_fields) {
}
}
if (i != 0)
if (auth->verbose_debug_passwords ||
else {
}
}
}
}
}
static void
struct auth_request *auth_request)
{
struct ldap_query_save_context ctx;
char *attr;
}
}
}
}
}
static LDAPMessage *
struct auth_request *auth_request,
{
enum passdb_result passdb_result;
int ret;
/* LDAP query returned something */
if (ret != LDAP_SUCCESS) {
"ldap_search(%s) failed: %s",
} else {
/* get the reply */
/* success */
return entry;
}
/* no entries returned */
"unknown user");
}
}
} else {
}
return NULL;
}
{
struct passdb_ldap_request *ldap_request =
(struct passdb_ldap_request *)request;
enum passdb_result passdb_result;
int ret;
return;
/* got first LDAP entry */
"No password in reply");
"pass_filter matched multiple objects, aborting");
} else {
/* passdb_password may change on the way,
so we'll need to strdup. */
}
/* auth_request_set_field() sets scheme */
/* LDAP's RFC2307 specifies the MD5 scheme for what we call PLAIN-MD5.
We can detect this case, because base64 doesn't use '$'. */
"Password doesn't look like MD5-CRYPT, "
"scheme changed to PLAIN-MD5");
scheme = "PLAIN-MD5";
}
} else {
}
}
}
struct ldap_request *ldap_request)
{
struct passdb_ldap_request *passdb_ldap_request =
(struct passdb_ldap_request *)ldap_request;
int msgid;
/* Assume that empty password fails. This is especially
important with Windows 2003 AD, which always returns success
with empty passwords. */
"Login attempt with empty password");
return;
}
/* switch back to the default dn before doing the next search
request */
/* the DN is kept in base variable, a bit ugly.. */
if (msgid == -1) {
"ldap_bind(%s) failed: %s",
return;
}
ldap_request->base);
} else {
}
/* Bind started */
}
static void
{
struct passdb_ldap_request *passdb_ldap_request =
(struct passdb_ldap_request *)ldap_request;
enum passdb_result passdb_result;
int ret;
if (ret == LDAP_SUCCESS)
else if (ret == LDAP_INVALID_CREDENTIALS) {
"invalid credentials");
} else {
"ldap_bind() failed: %s",
}
}
/* reconnected, retry binding */
} else {
}
}
static void
struct ldap_request *ldap_request,
{
struct passdb_ldap_request *passdb_ldap_request =
(struct passdb_ldap_request *)ldap_request;
return;
/* switch the handler to the authenticated bind handler */
ldap_request->base =
}
struct ldap_request *ldap_request)
{
struct ldap_passdb_module *module =
(struct ldap_passdb_module *)_module;
const struct var_expand_table *vars;
str_truncate(str, 0);
"base=%s scope=%s filter=%s fields=%s",
}
static void
struct ldap_request *ldap_request)
{
struct ldap_passdb_module *module =
(struct ldap_passdb_module *)_module;
const struct var_expand_table *vars;
}
static void
struct ldap_request *ldap_request)
{
struct ldap_passdb_module *module =
(struct ldap_passdb_module *)_module;
const struct var_expand_table *vars;
str_truncate(str, 0);
/* we don't need the attributes to perform authentication, but they
may contain some extra parameters. if a password is returned,
it's just ignored. */
"bind search: base=%s filter=%s",
}
static void
const char *password __attr_unused__,
{
struct ldap_passdb_module *module =
(struct ldap_passdb_module *)_module;
struct passdb_ldap_request *ldap_request;
/* reconnect if needed. this is also done by db_ldap_search(), but
with auth binds we'll have to do it ourself */
if (db_ldap_connect(conn)< 0) {
return;
}
else
}
{
struct passdb_ldap_request *ldap_request;
}
static struct passdb_module *
{
struct ldap_passdb_module *module;
struct ldap_connection *conn;
}
const char *args __attr_unused__)
{
struct ldap_passdb_module *module =
(struct ldap_passdb_module *)_module;
/* Credential lookups can't be done with authentication binds */
}
}
{
struct ldap_passdb_module *module =
(struct ldap_passdb_module *)_module;
}
struct passdb_module_interface passdb_ldap = {
"ldap",
};
#endif