db-ldap.h revision b6df44e31bf9d54669b5903dfb5dd3fbbe896acc
0536ccb51d41e3078c3a9fa33e509fb4b2420f95Timo Sirainen/* Functions like ldap_bind() have been deprecated in OpenLDAP 2.3
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainen This define enables them until the code here can be refactored */
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainen/* Maximum number of pending requests before delaying new requests. */
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen/* If LDAP connection is down, fail requests after waiting for this long. */
0dffa25d211be541ee3c953b23566a1a990789dfTimo Sirainen#define DB_LDAP_REQUEST_DISCONNECT_TIMEOUT_SECS 4
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainen/* If request is still in queue after this many seconds and other requests
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainen have been replied, assume the request was lost and abort it. */
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainen/* If server disconnects us, don't reconnect if no requests have been sent
a33b41b1dc19c692b1283049ec4de492fdadeb9aTimo Sirainen for this many seconds. */
1de2b5a16a455e018d8cbf72ee114d4b5d557a48Timo Sirainentypedef void db_search_callback_t(struct ldap_connection *conn,
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainen const char *dn;
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo Sirainen bool userdb_warning_disable; /* deprecated for now at least */
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo Sirainen /* Dovecot field name. */
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo Sirainen /* Field value template with %vars. NULL = same as LDAP value. */
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo Sirainen /* LDAP attribute name, or "" if this is a static field. */
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo Sirainen /* LDAP value contains a DN, which is looked up and used for @name
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo Sirainen attributes. */
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo Sirainen /* This attribute is used internally only via %{ldap_ptr},
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo Sirainen it shouldn't be returned in iteration. */
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo SirainenARRAY_DEFINE_TYPE(ldap_field, struct ldap_field);
d4fe93a9c242d745e0cf2e6cc58d5caf265de2a0Timo Sirainen /* msgid for sent requests, -1 if not sent */
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo Sirainen /* timestamp when request was created */
8ad2759cf4073e3bf4fcb9222a86e2153ed31875Timo Sirainen const char *dn;
a33b41b1dc19c692b1283049ec4de492fdadeb9aTimo Sirainen char **attributes; /* points to pass_attr_names / user_attr_names */
a33b41b1dc19c692b1283049ec4de492fdadeb9aTimo Sirainen ARRAY(struct ldap_request_named_result) named_results;
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainen const char *dn;
a0261d4fe4dfd422a051e474482e88785c04ee41Timo Sirainen /* Not connected */
a0261d4fe4dfd422a051e474482e88785c04ee41Timo Sirainen /* Binding - either to default dn or doing auth bind */
a0261d4fe4dfd422a051e474482e88785c04ee41Timo Sirainen /* Bound to auth dn */
a0261d4fe4dfd422a051e474482e88785c04ee41Timo Sirainen /* Bound to default dn */
a0261d4fe4dfd422a051e474482e88785c04ee41Timo Sirainen /* Request queue contains sent requests at tail (msgid != -1) and
a0261d4fe4dfd422a051e474482e88785c04ee41Timo Sirainen queued requests at head (msgid == -1). */
1de2b5a16a455e018d8cbf72ee114d4b5d557a48Timo Sirainen /* Number of messages in queue with msgid != -1 */
553667c748977991590854426255e1c34a615f24Timo Sirainen /* Timestamp when we last received a reply */
553667c748977991590854426255e1c34a615f24Timo Sirainen char **pass_attr_names, **user_attr_names, **iterate_attr_names;
c09f9f95db314e7482c95e502e1c56ed6c555797Timo Sirainen ARRAY_TYPE(ldap_field) pass_attr_map, user_attr_map, iterate_attr_map;
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainenvoid db_ldap_request(struct ldap_connection *conn,
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainenvoid db_ldap_set_attrs(struct ldap_connection *conn, const char *attrlist,
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainen char ***attr_names_r, ARRAY_TYPE(ldap_field) *attr_map,
a33b41b1dc19c692b1283049ec4de492fdadeb9aTimo Sirainenstruct ldap_connection *db_ldap_init(const char *config_path, bool userdb);
a33b41b1dc19c692b1283049ec4de492fdadeb9aTimo Sirainenvoid db_ldap_unref(struct ldap_connection **conn);
da2aa032ccfa8e7e4a4380ef738014549f4d2c2dTimo Sirainenint db_ldap_connect(struct ldap_connection *conn);
bf3fb941cc1deb06786449b89c77d9a56a07c251Timo Sirainenvoid db_ldap_enable_input(struct ldap_connection *conn, bool enable);
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainenconst char *ldap_get_error(struct ldap_connection *conn);
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainendb_ldap_result_iterate_init(struct ldap_connection *conn,
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainenbool db_ldap_result_iterate_next(struct db_ldap_result_iterate_context *ctx,
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainen const char **name_r,
5fe5ea74285e2fc0fbf7568c53f251aa894650fbTimo Sirainen const char *const **values_r);