* Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005 Regis Houssin * Copyright (C) 2006 Laurent Destailleur * * 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 2 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ */ /** \file htdocs/admin/ldap.php \ingroup ldap \brief Page d'administration/configuration du module Ldap \version $Revision$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/ldap.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/ldap.lib.php"); $langs->load("admin"); if (!$user->admin) accessforbidden(); /* * Actions */ if ($_GET["action"] == 'setvalue' && $user->admin) { $error=0; if (! dolibarr_set_const($db, 'LDAP_SERVER_TYPE',$_POST["type"])) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION',$_POST["version"])) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST',$_POST["host"])) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE',$_POST["slave"])) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_PORT',$_POST["port"])) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_DN',$_POST["dn"])) $error++; if (! dolibarr_set_const($db, 'LDAP_ADMIN_DN',$_POST["admin"])) $error++; if (! dolibarr_set_const($db, 'LDAP_ADMIN_PASS',$_POST["pass"])) $error++; if (! dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS',$_POST["usetls"])) $error++; if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE',$_POST["activecontact"])) $error++; if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE',$_POST["activesynchro"])) $error++; if (! dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE',$_POST["activemembers"])) $error++; if ($error) { dolibarr_print_error($db->error()); } } /* * Visu */ llxHeader(); $head = ldap_prepare_head(); // Test si fonction LDAP actives if (! function_exists("ldap_connect")) { $mesg=$langs->trans("LDAPFunctionsNotAvailableOnPHP"); } if ($mesg) print '
'.$mesg.'
'; dolibarr_fiche_head($head, 'ldap', $langs->trans("LDAPSetup")); $var=true; $html=new Form($db); print '
'; print ''; // Liste de synchro actives print ''; print ''; print "\n"; // Synchro utilisateurs/groupes active $var=!$var; print ''; // Synchro contact active if ($conf->societe->enabled) { $var=!$var; print ''; } // Synchro adherentt active if ($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 ''; $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"); $html->select_array('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"); $html->select_array('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"); $html->select_array('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'; $html->select_array('type',$arraylist,$conf->global->LDAP_SERVER_TYPE); print ' 
'.$langs->trans("Version").''; $arraylist=array(); $arraylist['3']='Version 3'; $arraylist['2']='Version 2'; $html->select_array('version',$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 ($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"); $html->select_array('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 ($conf->global->LDAP_ADMIN_PASS) { print '';// je le met en visible pour test } else { print ''; } print ' 
'; print '
'; print ''; /* * Test de la connexion */ if (function_exists("ldap_connect")) { if ($conf->global->LDAP_SERVER_HOST) { print ''.$langs->trans("LDAPTestConnect").'

'; } if ($_GET["action"] == 'test') { $ldap = new Ldap(); // Les parametres sont passés et récupérés via $conf $result = $ldap->connect_bind(); if ($result) { // 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 && $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,eregi_replace('.','*',$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,eregi_replace('.','*',$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('$Date$ - $Revision$'); ?>