* 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/authldap.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_MEMBERS_ACTIVE',$_POST["activemembers"])) $error++; if ($error) { dolibarr_print_error($db->error()); } } /* * Visu */ llxHeader(); print_fiche_titre($langs->trans("LDAPSetup"),'','setup'); // Test si fonction LDAP actives if (! function_exists("ldap_connect")) { $mesg=$langs->trans("LDAPFunctionsNotAvailableOnPHP"); } if ($mesg) print '
'.$mesg.'
'; else print '
'; // Onglets $h = 0; $head[$h][0] = DOL_URL_ROOT."/admin/ldap.php"; $head[$h][1] = $langs->trans("LDAPGlobalParameters"); $hselected=$h; $h++; if ($conf->global->LDAP_SYNCHRO_ACTIVE) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_users.php"; $head[$h][1] = $langs->trans("LDAPUsersAndGroupsSynchro"); $h++; } if ($conf->global->LDAP_CONTACT_ACTIVE) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_contacts.php"; $head[$h][1] = $langs->trans("LDAPContactsSynchro"); $h++; } if ($conf->global->LDAP_MEMBERS_ACTIVE) { $head[$h][0] = DOL_URL_ROOT."/admin/ldap_members.php"; $head[$h][1] = $langs->trans("LDAPMembersSynchro"); $h++; } dolibarr_fiche_head($head, $hselected, $langs->trans("LDAP")); $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 ''; // DNAdmin $var=!$var; print ''; // Pass $var=!$var; print ''; // Utiliser TLS $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_MEMBERS_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("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 ' 
'.$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").'
'; 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 AuthLdap(); // Les parametres sont passés et récupérés via $conf $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(); if ($bind) { 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 { print img_picto('','error').' '; print $langs->trans("LDAPTCPConnectKO",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT).' : '; print $ldap->ldapErrorCode." - ".$ldap->ldapErrorText; print "
"; } // Test ldap_getversion if (($ldap->getVersion() == 3)) { print img_picto('','info').' '; print ''.$langs->trans("LDAPSetupForVersion3").'
'; } else { print img_picto('','info').' '; print $langs->trans("LDAPSetupForVersion2").'
'; } // Test ldap_unbind $unbind = $ldap->unbind(); if ($unbind) { print img_picto('','info').' '; print ''.$langs->trans("LDAPUnbindSuccessfull").'
'; } else { print img_picto('','error').' '; print $langs->trans("LDAPUnbindFailed"); print "
"; print $ldap->ldapErrorCode." - ".$ldap->ldapErrorText; } } else { print img_picto('','error').' '; print $langs->trans("LDAPTCPConnectKO",$conf->global->LDAP_SERVER_HOST,$conf->global->LDAP_SERVER_PORT).'
'; print "
"; print $ldap->ldapErrorCode." - ".$ldap->ldapErrorText; print "
"; } } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>