cfdaa223525f87c9c980a25cc7bb6770a248d76aTimo Sirainen/* Functions like ldap_bind() have been deprecated in OpenLDAP 2.3
cfdaa223525f87c9c980a25cc7bb6770a248d76aTimo Sirainen This define enables them until the code here can be refactored */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen/* Maximum number of pending requests before delaying new requests. */
fb3178a1924dae52151d88c4d4ded879df43dd3fTimo Sirainen/* connect() timeout to LDAP */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen/* If LDAP connection is down, fail requests after waiting for this long. */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen#define DB_LDAP_REQUEST_DISCONNECT_TIMEOUT_SECS 4
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen/* If request is still in queue after this many seconds and other requests
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen have been replied, assume the request was lost and abort it. */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen/* If server disconnects us, don't reconnect if no requests have been sent
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen for this many seconds. */
965ed6ea3fc8f7637bd0d159d2fdb283a191ce34Timo Sirainentypedef void db_search_callback_t(struct ldap_connection *conn,
bf6c5e9028e7d8f31e92e5037b63c72a93ce3c5bTimo Sirainen bool userdb_warning_disable; /* deprecated for now at least */
6332ef7522d7a77a18c1bec4fc80d92ee597336cTimo Sirainen int ldap_deref, ldap_scope, ldap_tls_require_cert_parsed;
3fb1531681f9cbe49928f8e32357a692bf901c83Timo Sirainen /* Dovecot field name. */
3fb1531681f9cbe49928f8e32357a692bf901c83Timo Sirainen /* Field value template with %vars. NULL = same as LDAP value. */
3fb1531681f9cbe49928f8e32357a692bf901c83Timo Sirainen /* LDAP attribute name, or "" if this is a static field. */
3fb1531681f9cbe49928f8e32357a692bf901c83Timo Sirainen /* LDAP value contains a DN, which is looked up and used for @name
3fb1531681f9cbe49928f8e32357a692bf901c83Timo Sirainen attributes. */
626a206050bbe60b1f758c8918d09dad8accf225Timo Sirainen /* This attribute is used internally only via %{ldap_ptr},
626a206050bbe60b1f758c8918d09dad8accf225Timo Sirainen it shouldn't be returned in iteration. */
3fb1531681f9cbe49928f8e32357a692bf901c83Timo SirainenARRAY_DEFINE_TYPE(ldap_field, struct ldap_field);
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen /* msgid for sent requests, -1 if not sent */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen /* timestamp when request was created */
53e4a0d5cb048ea2bdf598ca56120b626b8615f5Martti Rannanjärvi /* This is to prevent double logging the result */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen char **attributes; /* points to pass_attr_names / user_attr_names */
3fb1531681f9cbe49928f8e32357a692bf901c83Timo Sirainen ARRAY(struct ldap_request_named_result) named_results;
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen /* Not connected */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen /* Binding - either to default dn or doing auth bind */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen /* Bound to auth dn */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen /* Bound to default dn */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen /* Request queue contains sent requests at tail (msgid != -1) and
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen queued requests at head (msgid == -1). */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen /* Number of messages in queue with msgid != -1 */
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainen /* Timestamp when we last received a reply */
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainen char **pass_attr_names, **user_attr_names, **iterate_attr_names;
0a8926b91a84abf462afdc1ed95def229377d7ffTimo Sirainen ARRAY_TYPE(ldap_field) pass_attr_map, user_attr_map, iterate_attr_map;
fc4ff2356fee6389d4cf2b3f12f4098a436f0502Timo Sirainenvoid db_ldap_request(struct ldap_connection *conn,
9f431ccfb6932746db56245c8a3d3415717ef545Timo Sirainenvoid db_ldap_set_attrs(struct ldap_connection *conn, const char *attrlist,
0a8926b91a84abf462afdc1ed95def229377d7ffTimo Sirainen char ***attr_names_r, ARRAY_TYPE(ldap_field) *attr_map,
964c86de7158ccafdfe665853579d71232e2634eTimo Sirainenstruct ldap_connection *db_ldap_init(const char *config_path, bool userdb);
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainenvoid db_ldap_unref(struct ldap_connection **conn);
16133a719ce8b6a5b8cedd721340cc1607c43433Timo Sirainenint db_ldap_connect(struct ldap_connection *conn);
99363aeac519d37553b7776b322e60b8a23cd2b9Timo Sirainenvoid db_ldap_connect_delayed(struct ldap_connection *conn);
43d3ea2780b5f8557ede7b4c039e8f56cb8d357dTimo Sirainenvoid db_ldap_enable_input(struct ldap_connection *conn, bool enable);
ebfcfd258acc89633c47d9c3b0b40a1a3f75cdcbTimo Sirainenconst char *ldap_get_error(struct ldap_connection *conn);
3fb1531681f9cbe49928f8e32357a692bf901c83Timo Sirainendb_ldap_result_iterate_init(struct ldap_connection *conn,
4261a8b43792dc4db4b39e6910319835b7450e84Timo Sirainenbool db_ldap_result_iterate_next(struct db_ldap_result_iterate_context *ctx,
3dadeec1ce7a5bf72fbd850658df1db3cedd4416Timo Sirainen const char **name_r,
3dadeec1ce7a5bf72fbd850658df1db3cedd4416Timo Sirainen const char *const **values_r);