diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php
index 27a84a5dedb..0dc997cc1f0 100644
--- a/htdocs/admin/ldap.php
+++ b/htdocs/admin/ldap.php
@@ -261,8 +261,9 @@ if (function_exists("ldap_connect"))
if ($conf->global->LDAP_SERVER_HOST && $conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS && $_GET["action"] == 'test')
{
+ $ldap = new Ldap();
// Test ldap_connect
- $ds = dolibarr_ldap_connect();
+ $ds = $ldap->dolibarr_ldap_connect();
if ($ds)
{
print img_picto('','info');
@@ -280,7 +281,7 @@ if (function_exists("ldap_connect"))
if ($ds)
{
// Test ldap_getversion
- if ((dolibarr_ldap_getversion($ds) == 3))
+ if (($ldap->dolibarr_ldap_getversion($ds) == 3))
{
print img_picto('','info');
print $langs->trans("LDAPSetupForVersion3").'
';
@@ -292,7 +293,7 @@ if (function_exists("ldap_connect"))
}
// Test ldap_bind
- $bind = @dolibarr_ldap_bind($ds);
+ $bind = $ldap->dolibarr_ldap_bind($ds);
if ($bind)
{
@@ -308,9 +309,9 @@ if (function_exists("ldap_connect"))
}
// Test ldap_unbind
- $unbind = @dolibarr_ldap_unbind($ds);
+ $unbind = $ldap->dolibarr_ldap_unbind($ds);
- if ($bind)
+ if ($unbind)
{
print img_picto('','info');
print "Déconnection du dn $dn réussi
";
diff --git a/htdocs/lib/ldap.lib.php b/htdocs/lib/ldap.lib.php
index c2d6c8dafb4..600e4511a65 100644
--- a/htdocs/lib/ldap.lib.php
+++ b/htdocs/lib/ldap.lib.php
@@ -33,6 +33,19 @@
Ensemble des fonctions permettant d'accèder à un serveur LDAP.
*/
+class Ldap
+{
+ var $err; // erreur ldap
+
+
+ /**
+ * \brief Constructeur de la classe
+ */
+ function Ldap()
+ {
+ $this->err = "";
+ }
+
/**
\brief Ouverture d'une connection vers le serveur LDAP
@@ -86,7 +99,7 @@ function dolibarr_ldap_bind($ds)
}
else
{
- $this->err = ldap_error($ldapbind);
+ $this->err = ldap_error($ds);
}
}
@@ -149,5 +162,6 @@ function dolibarr_ldap_unacc($str)
$stu = ereg_replace("ä","a",$stu);
return $stu;
}
+}
?>