#ifndef DB_LDAP_H
#define DB_LDAP_H
/* Functions like ldap_bind() have been deprecated in OpenLDAP 2.3
This define enables them until the code here can be refactored */
/* Maximum number of pending requests before delaying new requests. */
/* connect() timeout to LDAP */
/* If LDAP connection is down, fail requests after waiting for this long. */
/* If request is still in queue after this many seconds and other requests
have been replied, assume the request was lost and abort it. */
/* If server disconnects us, don't reconnect if no requests have been sent
for this many seconds. */
#include <ldap.h>
struct auth_request;
struct ldap_connection;
struct ldap_request;
struct ldap_request *request,
LDAPMessage *res);
struct ldap_settings {
const char *hosts;
const char *uris;
const char *dn;
const char *dnpass;
bool auth_bind;
const char *auth_bind_userdn;
bool tls;
bool sasl_bind;
const char *sasl_mech;
const char *sasl_realm;
const char *sasl_authz_id;
const char *tls_ca_cert_file;
const char *tls_ca_cert_dir;
const char *tls_cert_file;
const char *tls_key_file;
const char *tls_cipher_suite;
const char *tls_require_cert;
const char *deref;
const char *scope;
const char *base;
unsigned int ldap_version;
const char *ldaprc_path;
const char *debug_level;
const char *user_attrs;
const char *user_filter;
const char *pass_attrs;
const char *pass_filter;
const char *iterate_attrs;
const char *iterate_filter;
const char *default_pass_scheme;
bool blocking;
/* ... */
};
enum ldap_request_type {
};
struct ldap_field {
/* Dovecot field name. */
const char *name;
/* Field value template with %vars. NULL = same as LDAP value. */
const char *value;
/* LDAP attribute name, or "" if this is a static field. */
const char *ldap_attr_name;
/* LDAP value contains a DN, which is looked up and used for @name
attributes. */
bool value_is_dn;
/* This attribute is used internally only via %{ldap_ptr},
it shouldn't be returned in iteration. */
bool skip;
};
struct ldap_request {
/* msgid for sent requests, -1 if not sent */
int msgid;
/* timestamp when request was created */
/* This is to prevent double logging the result */
};
struct ldap_request_named_result {
const char *dn;
};
struct ldap_request_search {
const char *base;
const char *filter;
unsigned int name_idx;
bool multi_entry;
};
struct ldap_request_bind {
const char *dn;
};
enum ldap_connection_state {
/* Not connected */
/* Binding - either to default dn or doing auth bind */
/* Bound to auth dn */
/* Bound to default dn */
};
struct ldap_connection {
int refcount;
char *config_path;
int default_bind_msgid;
int fd;
/* Request queue contains sent requests at tail (msgid != -1) and
queued requests at head (msgid == -1). */
/* Number of messages in queue with msgid != -1 */
unsigned int pending_count;
/* Timestamp when we last received a reply */
bool userdb_used;
bool delayed_connect;
};
struct ldap_request *request);
const char *ldap_escape(const char *str,
const struct auth_request *auth_request);
struct db_ldap_result_iterate_context *
struct ldap_request_search *ldap_request,
const char **name_r,
const char *const **values_r);
#endif