* Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * * 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 (DOL_DOCUMENT_ROOT."/lib/ldap.lib.php"); $langs->load("admin"); if (!$user->admin) accessforbidden(); /* * Actions */ if ($_GET["action"] == 'setvalue' && $user->admin) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_HOST';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_SERVER_HOST','".$_POST["host"]."',0);"; $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_DN';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_SERVER_DN','".$_POST["dn"]."',0);"; $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_PASS';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_SERVER_PASS','".$_POST["pass"]."',0);"; $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_TYPE';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_SERVER_TYPE','".$_POST["type"]."',0);"; if ($db->query($sql)) { Header("Location: ldap.php"); } } llxHeader(); print_titre($langs->trans("LDAPSetup")); print '
'; print ''; print ''; print '
'; print ''; print ''; print ''; print ''; print "\n"; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'.$langs->trans("LDAPServer").''.LDAP_SERVER_HOST.'
'.$langs->trans("DN").''.LDAP_SERVER_DN.'
'.$langs->trans("Password").''.LDAP_SERVER_PASS.'
'.$langs->trans("Type").''.LDAP_SERVER_TYPE.'
'; print '
'; print '
'; print ''; print ''; print ''; print ''; print "\n"; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; print $langs->trans("LDAPServer").''; print ''; print '
'.$langs->trans("DN").''; print ''; print '
'.$langs->trans("Password").''; print ''; print '
'.$langs->trans("Type").''; print '
'; print '
'; /** * */ if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && $_GET["action"] == 'test') { print ''.$langs->trans("TestConnection").'
'; } if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && $_GET["action"] == 'test') { $ds = dolibarr_ldap_connect(); if ($ds) { print "connection au serveur ldap réussie
"; if ((dolibarr_ldap_getversion($ds) == 3)) { print "Serveur ldap configuré en version 3
"; } else { print "Serveur ldap configuré en version 2
"; } $bind = dolibarr_ldap_bind($ds); if ($bind) { print "connection au dn $dn réussi
"; } else { print "connection au dn $dn raté
"; } $unbind = dolibarr_ldap_unbind($ds); if ($bind) { print "déconnection du dn $dn réussi
"; } else { print "déconnection du dn $dn raté
"; } } else { print "connection au serveur ldap échouée
"; } } $db->close(); llxFooter(); ?>