Index: res/res_config_ldap.c =================================================================== --- res/res_config_ldap.c (révision 108395) +++ res/res_config_ldap.c (copie de travail) @@ -67,6 +67,7 @@ static char pass[50]; static char basedn[512]; static int port = 389; +static int version = 3; static time_t connect_time; static int parse_config(void); @@ -1423,10 +1424,18 @@ port = 389; ast_copy_string(host + strlen(host), ":389", sizeof(host)); } else { - ast_copy_string(host + 1, ":", sizeof(s)); - ast_copy_string(host + strlen(host), s, sizeof(s)); + ast_copy_string(host + strlen(host), ":", sizeof(host)); + ast_copy_string(host + strlen(host), s, sizeof(host)); port = atoi(s); } + + if (!(s = ast_variable_retrieve(config, "_general", "protocol"))) { + ast_log(LOG_WARNING, "No directory version found, using 3 as default.\n"); + version = 3; + } + else { + version = atoi(s); + } table_configs_free(); @@ -1480,6 +1489,10 @@ ast_log(LOG_ERROR, "Failed to init ldap connection to %s. Check debug for more info.\n", host); return 0; } + + if (LDAP_OPT_SUCCESS != ldap_set_option(ldapConn,LDAP_OPT_PROTOCOL_VERSION,&version)) { + ast_log(LOG_ERROR, "Failed to set ldap version %i. Staying on the default version (2). Check debug for more info.\n", host); + } if (!ast_strlen_zero(user)) { ast_debug(2, "bind to %s as %s\n", host, user);