]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dict-backend: switch to ldap_client_init_auto()
authorMarco Bettini <marco.bettini@open-xchange.com>
Mon, 9 Dec 2024 09:56:21 +0000 (09:56 +0000)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 17 Jan 2025 08:40:01 +0000 (10:40 +0200)
src/lib-dict-backend/dict-ldap-settings.c
src/lib-dict-backend/dict-ldap-settings.h
src/lib-dict-backend/dict-ldap.c

index 2eb2209a28615d576ca8e81f4346cc21b21fb21c..94e473a5dca43d063f5d6058c1fbe704d1cff177 100644 (file)
@@ -179,51 +179,6 @@ parse_setting(const char *key, const char *value,
 
        switch (ctx->type) {
        case SECTION_ROOT:
-               if (strcmp(key, "uri") == 0) {
-                       ctx->set->uri = p_strdup(ctx->pool, value);
-                       return NULL;
-               }
-               if (strcmp(key, "bind_dn") == 0) {
-                       ctx->set->bind_dn = p_strdup(ctx->pool, value);
-                       return NULL;
-               }
-               if (strcmp(key, "password") == 0) {
-                       ctx->set->password = p_strdup(ctx->pool, value);
-                       return NULL;
-               }
-               if (strcmp(key, "timeout") == 0) {
-                       if (str_to_uint(value, &ctx->set->timeout) != 0) {
-                               return "Invalid timeout value";
-                       }
-                       return NULL;
-               }
-               if (strcmp(key, "max_idle_time") == 0) {
-                       if (str_to_uint(value, &ctx->set->max_idle_time) != 0) {
-                               return "Invalid max_idle_time value";
-                       }
-                       return NULL;
-               }
-               if (strcmp(key, "debug") == 0) {
-                       if (str_to_uint(value, &ctx->set->debug) != 0) {
-                               return "invalid debug value";
-                       }
-                       return NULL;
-               }
-               if (strcmp(key, "tls") == 0) {
-                       if (strcasecmp(value, "yes") == 0) {
-                               ctx->set->require_ssl = TRUE;
-                               ctx->set->start_tls = TRUE;
-                       } else if (strcasecmp(value, "no") == 0) {
-                               ctx->set->require_ssl = FALSE;
-                               ctx->set->start_tls = FALSE;
-                       } else if (strcasecmp(value, "try") == 0) {
-                               ctx->set->require_ssl = FALSE;
-                               ctx->set->start_tls = TRUE;
-                       } else {
-                               return "tls must be yes, try or no";
-                       }
-                       return NULL;
-               }
                break;
        case SECTION_MAP:
                return parse_setting_from_defs(ctx->pool,
@@ -290,20 +245,9 @@ dict_ldap_settings_read(pool_t pool, const char *path, const char **error_r)
        t_array_init(&ctx.cur_attributes, 16);
        p_array_init(&ctx.set->parsed_maps, pool, 8);
 
-       ctx.set->timeout = 30; /* default timeout */
-       ctx.set->require_ssl = FALSE; /* try to start SSL */
-       ctx.set->start_tls = TRUE;
-
        if (!settings_read(path, NULL, parse_setting, parse_section,
                           &ctx, error_r))
                return NULL;
-
-       if (ctx.set->uri == NULL) {
-               *error_r = t_strdup_printf("Error in configuration file %s: "
-                                          "Missing ldap uri", path);
-               return NULL;
-       }
-
        return ctx.set;
 }
 
index 5f78fcee4ed736cf48e8fa1ae77a6df41a32aa70..74835265b18f9873806e991e60efeb25db65200c 100644 (file)
@@ -18,14 +18,6 @@ struct dict_ldap_map_settings {
 };
 
 struct dict_ldap_settings {
-       const char *uri;
-       const char *bind_dn;
-       const char *password;
-       unsigned int timeout;
-       unsigned int max_idle_time;
-       unsigned int debug;
-       bool require_ssl;
-       bool start_tls;
        ARRAY(struct dict_ldap_map_settings) parsed_maps;
 };
 
index 80adf978437d4338781dcbc78b39bb5ad4083548..be140f1bd7ca2794958feb1c904e1fdb2af27101 100644 (file)
@@ -121,18 +121,7 @@ ldap_dict_find_map(struct ldap_dict *dict, const char *path,
 static
 int dict_ldap_connect(struct ldap_dict *dict, const char **error_r)
 {
-       struct ldap_client_settings set;
-       i_zero(&set);
-       set.uris = dict->set->uri;
-       set.auth_dn = dict->set->bind_dn;
-       set.auth_dn_password = dict->set->password;
-       set.timeout_secs = dict->set->timeout;
-       set.max_idle_time_secs = dict->set->max_idle_time;
-       set.debug_level = dict->set->debug;
-       set.require_ssl = dict->set->require_ssl;
-       set.starttls = dict->set->start_tls;
-       set.event_parent = dict->event;
-       return ldap_client_init(&set, &dict->client, error_r);
+       return ldap_client_init_auto(dict->event, &dict->client, error_r);
 }
 
 #define IS_LDAP_ESCAPED_CHAR(c) \