[asterisk-bugs] [Asterisk 0012211]: The LDAP version is not taken into account

noreply at bugs.digium.com noreply at bugs.digium.com
Fri Mar 14 05:17:25 CDT 2008


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=12211 
====================================================================== 
Reported By:                sylvain
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   12211
Category:                   Resources/res_config_ldap
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
Asterisk Version:           SVN 
SVN Branch (only for SVN checkouts, not tarball releases): 1.6.0 
SVN Revision (number only!): 108395 
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             03-14-2008 05:00 CDT
Last Modified:              03-14-2008 05:17 CDT
====================================================================== 
Summary:                    The LDAP version is not taken into account
Description: 
if a version of LDAP protocol is set in general like here:
[_general]
host=linuxsde ; LDAP host(s)
port=10389 ;
protocol=3 ; Version of the LDAP protocol to use default is 3.
basedn=system ; Base DN
pass=secret ; Bind password
user=admin ; Bind DN

it is not taken into account and the protocol version is 2.
After code investigation, it seems that "version" is not read. I give in
additionnal Information the patch which make it work for 1.6.0 branch (with
previous patch making ldap working with unstandard port)
====================================================================== 

---------------------------------------------------------------------- 
 sylvain - 03-14-08 05:17  
---------------------------------------------------------------------- 
made a mistake, here's a new patch:

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); 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
03-14-08 05:17  sylvain        Note Added: 0083939                          
======================================================================




More information about the asterisk-bugs mailing list