From 75a82a31ce605e58f0a4a500fb7ae5862acbadaa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 18 Nov 2006 16:09:42 +0000 Subject: [PATCH] Ajout gestion authentification dans test LDAP --- htdocs/admin/ldap.php | 29 ++++++++++++++++++++++++++--- htdocs/admin/ldap_contacts.php | 12 +++++++++--- htdocs/langs/en_US/admin.lang | 3 +++ htdocs/langs/fr_FR/admin.lang | 7 +++++-- 4 files changed, 43 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 15140b45a87..89c1006b4fc 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -292,7 +292,7 @@ print ''; */ if (function_exists("ldap_connect")) { - if ($conf->global->LDAP_SERVER_HOST && $conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS) + if ($conf->global->LDAP_SERVER_HOST) { print ''.$langs->trans("LDAPTestConnect").'

'; } @@ -301,8 +301,8 @@ if (function_exists("ldap_connect")) { $ldap = new AuthLdap(); // Les parametres sont passés et récupérés via $conf - $ds = $ldap->connect(); - if ($ds) + $result = $ldap->connect(); // Avec OpenLDAP 2.x.x, $reslt sera toujours vrai car connection a lieu dans premeiere fonction ldap_* + if ($result) { // Test ldap_bind $bind = $ldap->bind(); @@ -310,6 +310,28 @@ if (function_exists("ldap_connect")) { print img_picto('','info').' '; print ''.$langs->trans("LDAPTCPConnectOK",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT).'
'; + + if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS) + { + $authbind = $ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS); + if ($authbind) + { + print img_picto('','info').' '; + print ''.$langs->trans("LDAPBindOK",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT,$conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS).'
'; + } + else + { + print img_picto('','error').' '; + print ''.$langs->trans("LDAPBindKO",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT,$conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS).' : '; + print $ldap->ldapErrorCode." - ".$ldap->ldapErrorText; + print "
"; + } + } + else + { + print img_picto('','warning').' '; + print ''.$langs->trans("LDAPNoUserOrPasswordProvidedAccessIsReadOnly").'
'; + } } else { @@ -319,6 +341,7 @@ if (function_exists("ldap_connect")) print "
"; } + // Test ldap_getversion if (($ldap->getVersion() == 3)) { diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index abc9d41f305..9270529646f 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -54,7 +54,10 @@ if (!$user->admin) if ($_GET["action"] == 'setvalue' && $user->admin) { - + if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN',$_POST["contactdn"])) + { + print $db->error(); + } } @@ -121,8 +124,11 @@ $var=true; $html=new Form($db); -// Not available -print ''.$langs->trans("LDAPParametersAreStillHardCoded").''; +// DN Pour les contacts +$var=!$var; +print ''.$langs->trans("LDAPContactDn").''; +print ''; +print ''.$langs->trans("LDAPContactDnExample").''; print ''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index ae6c306617a..2be50a082b8 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -529,6 +529,8 @@ LDAPContactDnExample=Complete DN (ex: ou=contacts,dc=society,dc=com) LDAPTestConnect=Test LDAP connection LDAPTCPConnectOK=TCP connect to LDAP server successful (Server=%s, Port=%s) LDAPTCPConnectKO=TCP connect to LDAP server failed (Server=%s, Port=%s) +LDAPBindOK=Connect/Authentificate to LDAP server sucessfull (Server=%s, Port=%s, Admin=%s) +LDAPBindKO=Connect/Authentificate to LDAP server failed (Server=%s, Port=%s, Admin=%s) LDAPUnbindSuccessfull=Disconnect successfull LDAPUnbindFailed=Disconnect failed LDAPConnectToDNSuccessfull=Connection au DN (%s) réussie @@ -556,6 +558,7 @@ LDAPFieldMobile=Cellular phone LDAPFieldMobileExample=Default attribute : mobile LDAPParametersAreStillHardCoded=LDAP parametres are still hardcoded (in contact class) LDAPSetupNotComplete=LDAP setup not complete (go on others tabs) +LDAPNoUserOrPasswordProvidedAccessIsReadOnly=No administrator or password provided. LDAP access will be anonymous and in read only mode. ##### Products ##### ProductSetup=Products module setup NumberOfProductShowInSelect=Max number of products in combos select lists (0=no limit) diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 48fec98d506..312fe02892b 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -527,8 +527,10 @@ LDAPDnContactActiveExample=Synchronisation activ LDAPContactDn=DN des contacts Dolibarr LDAPContactDnExample=DN complet (ex: ou=contacts,dc=societe,dc=com) LDAPTestConnect=Tester la connexion LDAP -LDAPTCPConnectOK=Connexion TCP au serveur LDAP réussie (Server=%s, Port=%s) -LDAPTCPConnectKO=Connexion TCP au serveur LDAP échouée (Server=%s, Port=%s) +LDAPTCPConnectOK=Connexion TCP au serveur LDAP réussie (Serveur=%s, Port=%s) +LDAPTCPConnectKO=Connexion TCP au serveur LDAP échouée (Serveur=%s, Port=%s) +LDAPBindOK=Connection/Authentification au serveur LDAP réussie (Serveur=%s, Port=%s, Admin=%s) +LDAPBindKO=Connection/Authentification au serveur LDAP échouée (Serveur=%s, Port=%s, Admin=%s) LDAPUnbindSuccessfull=Déconnection réussie LDAPUnbindFailed=Déconnection échouée LDAPConnectToDNSuccessfull=Connection au DN (%s) réussie @@ -556,6 +558,7 @@ LDAPFieldMobile=T LDAPFieldMobileExample=Attribut par défaut : mobile LDAPParametersAreStillHardCoded=Les parametres LDAP sont codés en dur (dans classe contact) LDAPSetupNotComplete=Configuration LDAP incomplète (à compléter sur les autres onglets) +LDAPNoUserOrPasswordProvidedAccessIsReadOnly=Administrateur ou mot de passe non renseigné. Les accès LDAP seront donc anonymes et en lecture seule. ##### Products ##### ProductSetup=Configuration du module Produits NumberOfProductShowInSelect=Nombre de produits max dans les listes déroulantes (0=aucune limite)