début amélioration LDAP

This commit is contained in:
Regis Houssin 2006-06-12 14:05:23 +00:00
parent 32fa237a5b
commit 777ef01c0a
2 changed files with 21 additions and 6 deletions

View File

@ -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') 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 // Test ldap_connect
$ds = dolibarr_ldap_connect(); $ds = $ldap->dolibarr_ldap_connect();
if ($ds) if ($ds)
{ {
print img_picto('','info'); print img_picto('','info');
@ -280,7 +281,7 @@ if (function_exists("ldap_connect"))
if ($ds) if ($ds)
{ {
// Test ldap_getversion // Test ldap_getversion
if ((dolibarr_ldap_getversion($ds) == 3)) if (($ldap->dolibarr_ldap_getversion($ds) == 3))
{ {
print img_picto('','info'); print img_picto('','info');
print $langs->trans("LDAPSetupForVersion3").'<br>'; print $langs->trans("LDAPSetupForVersion3").'<br>';
@ -292,7 +293,7 @@ if (function_exists("ldap_connect"))
} }
// Test ldap_bind // Test ldap_bind
$bind = @dolibarr_ldap_bind($ds); $bind = $ldap->dolibarr_ldap_bind($ds);
if ($bind) if ($bind)
{ {
@ -308,9 +309,9 @@ if (function_exists("ldap_connect"))
} }
// Test ldap_unbind // Test ldap_unbind
$unbind = @dolibarr_ldap_unbind($ds); $unbind = $ldap->dolibarr_ldap_unbind($ds);
if ($bind) if ($unbind)
{ {
print img_picto('','info'); print img_picto('','info');
print "Déconnection du dn $dn réussi<br>"; print "Déconnection du dn $dn réussi<br>";

View File

@ -33,6 +33,19 @@
Ensemble des fonctions permettant d'accèder à un serveur LDAP. 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 \brief Ouverture d'une connection vers le serveur LDAP
@ -86,7 +99,7 @@ function dolibarr_ldap_bind($ds)
} }
else 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); $stu = ereg_replace("ä","a",$stu);
return $stu; return $stu;
} }
}
?> ?>