* Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005 Regis Houssin * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2011-2013 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/admin/ldap.php * \ingroup ldap * \brief Page d'administration/configuration du module Ldap */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; $langs->load("admin"); if (!$user->admin) accessforbidden(); $action = GETPOST("action"); /* * Actions */ if ($action == 'setvalue' && $user->admin) { $error=0; $db->begin(); if (! dolibarr_set_const($db, 'LDAP_SERVER_TYPE',GETPOST("type"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION',GETPOST("LDAP_SERVER_PROTOCOLVERSION"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST',GETPOST("host"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE',GETPOST("slave"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_PORT',GETPOST("port"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_DN',GETPOST("dn"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_ADMIN_DN',GETPOST("admin"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_ADMIN_PASS',GETPOST("pass"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS',GETPOST("usetls"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE',GETPOST("activesynchro"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE',GETPOST("activecontact"),'chaine',0,'',$conf->entity)) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE',GETPOST("activemembers"),'chaine',0,'',$conf->entity)) $error++; if (! $error) { $db->commit(); setEventMessage($langs->trans("SetupSaved")); } else { $db->rollback(); dol_print_error($db); } } /* * View */ llxHeader('',$langs->trans("LDAPSetup"),'EN:Module_LDAP_En|FR:Module_LDAP|ES:Módulo_LDAP'); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("LDAPSetup"),$linkback,'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives if (! function_exists("ldap_connect")) { setEventMessage($langs->trans("LDAPFunctionsNotAvailableOnPHP"),'errors'); } dol_fiche_head($head, 'ldap', $langs->trans("LDAPSetup")); $var=true; $form=new Form($db); print '
'; print ''; print ''; // Liste de synchro actives print ''; print ''; print "\n"; // Synchro utilisateurs/groupes active $var=!$var; print ''; // Synchro contact active if (! empty($conf->societe->enabled)) { $var=!$var; print ''; } // Synchro adherentt active if (! empty($conf->adherent->enabled)) { $var=!$var; print ''; } print ''; print ''; print ''; print ''; print "\n"; // Type $var=!$var; print ''; // Version $var=!$var; print ''; // Serveur primaire $var=!$var; print ''; // Serveur secondaire $var=!$var; print ''; // Port $var=!$var; print ''; // DNserver $var=!$var; print ''; // Utiliser TLS $var=!$var; print ''; print ''; print ''; print "\n"; // DNAdmin $var=!$var; print ''; // Pass $var=!$var; print ''; print '
'.$langs->trans("LDAPSynchronization").'
'.$langs->trans("LDAPDnSynchroActive").''; $arraylist=array(); $arraylist['0']=$langs->trans("No"); $arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr"); $arraylist['dolibarr2ldap']=$langs->trans("DolibarrToLDAP"); print $form->selectarray('activesynchro',$arraylist,$conf->global->LDAP_SYNCHRO_ACTIVE); print ''.$langs->trans("LDAPDnSynchroActiveExample"); if ($conf->global->LDAP_SYNCHRO_ACTIVE && ! $conf->global->LDAP_USER_DN) { print '
'.$langs->trans("LDAPSetupNotComplete").''; } print '
'.$langs->trans("LDAPDnContactActive").''; $arraylist=array(); $arraylist['0']=$langs->trans("No"); $arraylist['1']=$langs->trans("DolibarrToLDAP"); print $form->selectarray('activecontact',$arraylist,$conf->global->LDAP_CONTACT_ACTIVE); print ''.$langs->trans("LDAPDnContactActiveExample").'
'.$langs->trans("LDAPDnMemberActive").''; $arraylist=array(); $arraylist['0']=$langs->trans("No"); $arraylist['1']=$langs->trans("DolibarrToLDAP"); print $form->selectarray('activemembers',$arraylist,$conf->global->LDAP_MEMBER_ACTIVE); print ''.$langs->trans("LDAPDnMemberActiveExample").'
'.$langs->trans("Parameter").''.$langs->trans("Value").''.$langs->trans("Example").'
'.$langs->trans("Type").''; $arraylist=array(); $arraylist['activedirectory']='Active Directory'; $arraylist['openldap']='OpenLdap'; $arraylist['egroupware']='Egroupware'; print $form->selectarray('type',$arraylist,$conf->global->LDAP_SERVER_TYPE); print ' 
'.$langs->trans("Version").''; $arraylist=array(); $arraylist['3']='Version 3'; $arraylist['2']='Version 2'; print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION',$arraylist,$conf->global->LDAP_SERVER_PROTOCOLVERSION); print ''.$langs->trans("LDAPServerProtocolVersion").'
'; print $langs->trans("LDAPPrimaryServer").''; print ''; print ''.$langs->trans("LDAPServerExample").'
'; print $langs->trans("LDAPSecondaryServer").''; print ''; print ''.$langs->trans("LDAPServerExample").'
'.$langs->trans("LDAPServerPort").''; if (! empty($conf->global->LDAP_SERVER_PORT)) { print ''; } else { print ''; } print ''.$langs->trans("LDAPServerPortExample").'
'.$langs->trans("LDAPServerDn").''; print ''; print ''.$langs->trans("LDAPServerDnExample").'
'.$langs->trans("LDAPServerUseTLS").''; $arraylist=array(); $arraylist['0']=$langs->trans("No"); $arraylist['1']=$langs->trans("Yes"); print $form->selectarray('usetls',$arraylist,$conf->global->LDAP_SERVER_USE_TLS); print ''.$langs->trans("LDAPServerUseTLSExample").'
'.$langs->trans("ForANonAnonymousAccess").'
'.$langs->trans("LDAPAdminDn").''; print ''; print ''.$langs->trans("LDAPAdminDnExample").'
'.$langs->trans("LDAPPassword").''; if (! empty($conf->global->LDAP_ADMIN_PASS)) { print '';// je le met en visible pour test } else { print ''; } print 'secret
'; print '
'; print '
'; print ''; print '
'; /* * Test de la connexion */ if (function_exists("ldap_connect")) { if (! empty($conf->global->LDAP_SERVER_HOST)) { print ''.$langs->trans("LDAPTestConnect").'

'; } if ($_GET["action"] == 'test') { $ldap = new Ldap(); // Les parametres sont passes et recuperes via $conf $result = $ldap->connect_bind(); if ($result > 0) { // Test ldap connect and bind print img_picto('','info').' '; print ''.$langs->trans("LDAPTCPConnectOK",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT).''; print '
'; if ($conf->global->LDAP_ADMIN_DN && ! empty($conf->global->LDAP_ADMIN_PASS)) { if ($result == 2) { print img_picto('','info').' '; print ''.$langs->trans("LDAPBindOK",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT,$conf->global->LDAP_ADMIN_DN,preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)).''; print '
'; } else { print img_picto('','error').' '; print ''.$langs->trans("LDAPBindKO",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT,$conf->global->LDAP_ADMIN_DN,preg_replace('/./i','*',$conf->global->LDAP_ADMIN_PASS)).''; print '
'; print $langs->trans("Error").' '.$ldap->error; print '
'; } } else { print img_picto('','warning').' '; print ''.$langs->trans("LDAPNoUserOrPasswordProvidedAccessIsReadOnly").''; print '
'; } // Test ldap_getversion if (($ldap->getVersion() == 3)) { print img_picto('','info').' '; print ''.$langs->trans("LDAPSetupForVersion3").''; print '
'; } else { print img_picto('','info').' '; print ''.$langs->trans("LDAPSetupForVersion2").''; print '
'; } $unbind = $ldap->unbind(); } else { print img_picto('','error').' '; print ''.$langs->trans("LDAPTCPConnectKO",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT).''; print '
'; print $langs->trans("Error").' '.$ldap->error; print '
'; } } } $db->close(); llxFooter();