diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php
index 9e0531cfb7d..571d86caba0 100644
--- a/htdocs/admin/ldap.php
+++ b/htdocs/admin/ldap.php
@@ -48,6 +48,13 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES
('LDAP_SERVER_HOST','".$_POST["host"]."',0);";
$db->query($sql);
+
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_PORT';";
+ $db->query($sql);
+
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES
+ ('LDAP_SERVER_PORT','".$_POST["port"]."',0);";
+ $db->query($sql);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SUFFIX_DN';";
$db->query($sql);
@@ -137,6 +144,14 @@ print "\n";
{
print '
| '.$langs->trans("LDAPServer").' | '.$langs->trans("LDAPServerExample").' |
';
}
+ if (defined("LDAP_SERVER_PORT") && LDAP_SERVER_PORT)
+ {
+ print '| '.$langs->trans("LDAPServerPort").' | '.LDAP_SERVER_PORT.' |
';
+ }
+ else
+ {
+ print '| '.$langs->trans("LDAPServerPort").' | '.$langs->trans("LDAPServerPortExample").' |
';
+ }
if (defined("LDAP_SUFFIX_DN") && LDAP_SUFFIX_DN)
{
print '| '.$langs->trans("LDAPSuffix").' | '.LDAP_SUFFIX_DN.' |
';
@@ -221,6 +236,16 @@ print '| ';
print $langs->trans("LDAPServer").' | ';
print '';
print ' |
';
+print '| '.$langs->trans("LDAPServerPort").' | ';
+if (defined("LDAP_SERVER_PORT") && LDAP_SERVER_PORT)
+{
+ print '';
+}
+else
+{
+ print '';
+}
+print ' |
';
print '| '.$langs->trans("LDAPSuffix").' | ';
print '';
print ' |
';
@@ -295,11 +320,17 @@ if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST) {
if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && LDAP_ADMIN_DN && LDAP_ADMIN_PASS && $_GET["action"] == 'test')
{
$ds = dolibarr_ldap_connect();
-
+/*
if ($ds)
{
- print "connection au serveur ldap réussie
";
-
+ print "connexion au serveur ldap réussie
";
+ }
+ else
+ {
+ print "connexion au serveur ldap échouée";
+ print img_picto('','alerte');
+ print "
";
+ }
if ((dolibarr_ldap_getversion($ds) == 3))
{
print "Serveur ldap configuré en version 3
";
@@ -308,21 +339,21 @@ if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && LDAP_ADMIN_DN && LDAP_ADM
{
print "Serveur ldap configuré en version 2
";
}
-
- $bind = dolibarr_ldap_bind($ds);
+*/
+ $bind = @dolibarr_ldap_bind($ds);
if ($bind)
{
- print "connection au dn $dn réussi
";
+ print "connexion au dn $dn réussi
";
}
else
{
- print "connection au dn $dn raté";
+ print "connexion au dn $dn raté";
print img_picto('','alerte');
print "
";
}
- $unbind = dolibarr_ldap_unbind($ds);
+ $unbind = @dolibarr_ldap_unbind($ds);
if ($bind)
{
@@ -334,11 +365,6 @@ if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && LDAP_ADMIN_DN && LDAP_ADM
print img_picto('','alerte');
print "
";
}
- }
- else
- {
- print "connection au serveur ldap échouée
";
- }
}
$db->close();
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index c295013af66..841c9b149b6 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -265,6 +265,8 @@ InterventionsSetup=Interventions module setup
##### LDAP setup ####
LDAPSetup=LDAP Setup
LDAPServer=LDAP Server
+LDAPServerPort=LDAP server port
+LDAPServerPortExample=Default port : 389
TestConnectLdap=Test connection
LDAPSuffix=LDAP suffix
DNAdmin=LDAP Administrator
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 03d799f6260..17b21dffd09 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -265,6 +265,8 @@ InterventionsSetup=Configuration du module Interventions
##### LDAP setup #####
LDAPSetup=Configuration du module LDAP
LDAPServer=Serveur LDAP
+LDAPServerPort=Port du serveur LDAP
+LDAPServerPortExample=Port par défaut : 389
TestConnectLdap=Tester la connexion
LDAPSuffix=Suffix LDAP
DNAdmin=Administrateur LDAP
diff --git a/htdocs/lib/ldap.lib.php b/htdocs/lib/ldap.lib.php
index b5fcd24e26c..512e540b582 100644
--- a/htdocs/lib/ldap.lib.php
+++ b/htdocs/lib/ldap.lib.php
@@ -40,8 +40,8 @@
function dolibarr_ldap_connect()
{
- $ldapconnect = ldap_connect(LDAP_SERVER_HOST);
-
+ $ldapconnect = ldap_connect(LDAP_SERVER_HOST,LDAP_SERVER_PORT);
+
return $ldapconnect;
}