2004-10-19 20:58:50 +02:00
|
|
|
|
<?php
|
2004-01-23 13:42:17 +01:00
|
|
|
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2004-09-02 23:14:20 +02:00
|
|
|
|
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
|
|
|
|
|
|
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
2004-01-23 13:42:17 +01:00
|
|
|
|
*
|
|
|
|
|
|
* 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$
|
|
|
|
|
|
*/
|
2004-06-18 20:34:41 +02:00
|
|
|
|
|
2004-08-29 14:01:58 +02:00
|
|
|
|
/*! \file htdocs/admin/ldap.php
|
|
|
|
|
|
\ingroup ldap
|
|
|
|
|
|
\brief Page d'administration/configuration du module Ldap
|
|
|
|
|
|
\version $Revision$
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2004-01-23 13:42:17 +01:00
|
|
|
|
require("./pre.inc.php");
|
2004-01-23 14:31:09 +01:00
|
|
|
|
require (DOL_DOCUMENT_ROOT."/lib/ldap.lib.php");
|
2004-01-23 13:42:17 +01:00
|
|
|
|
|
2004-08-29 14:01:58 +02:00
|
|
|
|
$langs->load("admin");
|
|
|
|
|
|
|
|
|
|
|
|
if (!$user->admin)
|
|
|
|
|
|
accessforbidden();
|
|
|
|
|
|
|
2005-01-16 18:00:11 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* Actions
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2004-01-23 13:42:17 +01:00
|
|
|
|
if ($_GET["action"] == 'setvalue' && $user->admin)
|
|
|
|
|
|
{
|
2004-09-11 01:17:33 +02:00
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_HOST';";
|
2004-12-01 12:26:19 +01:00
|
|
|
|
$db->query($sql);
|
2004-09-11 01:17:33 +02:00
|
|
|
|
|
2004-12-01 12:26:19 +01:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES
|
|
|
|
|
|
('LDAP_SERVER_HOST','".$_POST["host"]."',0);";
|
|
|
|
|
|
|
2004-01-23 13:42:17 +01:00
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
2004-09-11 01:17:33 +02:00
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_DN';";
|
2004-12-01 12:26:19 +01:00
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES
|
2004-09-04 14:55:30 +02:00
|
|
|
|
('LDAP_SERVER_DN','".$_POST["dn"]."',0);";
|
2004-01-23 13:42:17 +01:00
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
2004-12-01 12:26:19 +01:00
|
|
|
|
$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
|
2004-09-04 14:55:30 +02:00
|
|
|
|
('LDAP_SERVER_PASS','".$_POST["pass"]."',0);";
|
2004-09-11 01:17:33 +02:00
|
|
|
|
|
2004-01-23 13:42:17 +01:00
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
2004-09-11 01:17:33 +02:00
|
|
|
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_TYPE';";
|
2004-01-23 13:42:17 +01:00
|
|
|
|
$db->query($sql);
|
|
|
|
|
|
|
2004-12-01 12:26:19 +01:00
|
|
|
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES
|
|
|
|
|
|
('LDAP_SERVER_TYPE','".$_POST["type"]."',0);";
|
2004-01-23 13:42:17 +01:00
|
|
|
|
|
|
|
|
|
|
if ($db->query($sql))
|
|
|
|
|
|
{
|
|
|
|
|
|
Header("Location: ldap.php");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-06-18 20:34:41 +02:00
|
|
|
|
|
2005-01-16 18:00:11 +01:00
|
|
|
|
llxHeader();
|
|
|
|
|
|
|
|
|
|
|
|
print_titre($langs->trans("LDAPSetup"));
|
2004-06-18 20:34:41 +02:00
|
|
|
|
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<br>';
|
|
|
|
|
|
print '<table class="noborder" width="100%">';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
print '<tr>';
|
|
|
|
|
|
print '<td width="50%" valign="top">';
|
|
|
|
|
|
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<table class="border" width="100%">';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
print '<tr class="liste_titre">';
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<td>'.$langs->trans("Parameter").'</td>';
|
|
|
|
|
|
print '<td>'.$langs->trans("Value").'</td><td colspan="2"> </td>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
print "</tr>\n";
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<tr><td>'.$langs->trans("LDAPServer").'</td><td>'.LDAP_SERVER_HOST.'</td></tr>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<tr><td>'.$langs->trans("DN").'</td><td>'.LDAP_SERVER_DN.'</td></tr>';
|
|
|
|
|
|
print '<tr><td>'.$langs->trans("Password").'</td><td>'.LDAP_SERVER_PASS.'</td></tr>';
|
2004-08-29 21:03:50 +02:00
|
|
|
|
print '<tr><td>'.$langs->trans("Type").'</td><td>'.LDAP_SERVER_TYPE.'</td></tr>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
|
|
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
|
|
print '</td><td width="50%">';
|
|
|
|
|
|
|
|
|
|
|
|
print '<form method="post" action="ldap.php?action=setvalue">';
|
|
|
|
|
|
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<table class="border" width="100%">';
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
|
print '<td>'.$langs->trans("Parameter").'</td>';
|
|
|
|
|
|
print '<td>'.$langs->trans("Value").'</td><td colspan="2"> </td>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
print '<tr><td>';
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print $langs->trans("LDAPServer").'</td><td>';
|
|
|
|
|
|
print '<input size="25" type="text" name="host" value="'.LDAP_SERVER_HOST.'">';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
print '</td></tr>';
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<tr><td>'.$langs->trans("DN").'</td><td>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
print '<input size="25" type="text" name="dn" value="'.LDAP_SERVER_DN.'">';
|
|
|
|
|
|
print '</td></tr>';
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<tr><td>'.$langs->trans("Password").'</td><td>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
print '<input size="25" type="text" name="pass" value="'.LDAP_SERVER_PASS.'">';
|
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<tr><td>'.$langs->trans("Type").'</td><td><select name="type">';
|
2004-06-15 20:13:55 +02:00
|
|
|
|
print '<option value="openldap" selected>OpenLdap';
|
|
|
|
|
|
print '<option value="egroupware">Egroupware';
|
|
|
|
|
|
print '</select>';
|
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<tr><td colspan="2" align="center"><input type="submit" value="'.$langs->trans("Modify").'"></td></tr>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
print '</table></form>';
|
|
|
|
|
|
|
|
|
|
|
|
print '</td></tr></table>';
|
|
|
|
|
|
|
2004-06-18 20:34:41 +02:00
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2005-01-16 18:00:11 +01:00
|
|
|
|
if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && $_GET["action"] == 'test') {
|
|
|
|
|
|
print '<a class="tabAction" href="ldap.php?action=test">'.$langs->trans("TestConnection").'</a><br>';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-01-23 13:42:17 +01:00
|
|
|
|
|
2004-01-23 14:31:09 +01:00
|
|
|
|
if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && $_GET["action"] == 'test')
|
2004-01-23 13:42:17 +01:00
|
|
|
|
{
|
2004-01-23 14:31:09 +01:00
|
|
|
|
$ds = dolibarr_ldap_connect();
|
2004-01-23 13:42:17 +01:00
|
|
|
|
|
|
|
|
|
|
if ($ds)
|
|
|
|
|
|
{
|
2004-06-15 22:17:49 +02:00
|
|
|
|
print "connection au serveur ldap r<>ussie<br>";
|
|
|
|
|
|
|
2004-06-17 18:49:20 +02:00
|
|
|
|
if ((dolibarr_ldap_getversion($ds) == 3))
|
2004-06-15 22:17:49 +02:00
|
|
|
|
{
|
|
|
|
|
|
print "Serveur ldap configur<75> en version 3<br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print "Serveur ldap configur<75> en version 2<br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$bind = dolibarr_ldap_bind($ds);
|
|
|
|
|
|
|
|
|
|
|
|
if ($bind)
|
|
|
|
|
|
{
|
|
|
|
|
|
print "connection au dn $dn r<>ussi<br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print "connection au dn $dn rat<61><br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2004-06-17 18:49:20 +02:00
|
|
|
|
$unbind = dolibarr_ldap_unbind($ds);
|
2004-06-15 22:17:49 +02:00
|
|
|
|
|
|
|
|
|
|
if ($bind)
|
|
|
|
|
|
{
|
|
|
|
|
|
print "d<EFBFBD>connection du dn $dn r<>ussi<br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print "d<EFBFBD>connection du dn $dn rat<61><br>";
|
|
|
|
|
|
}
|
2004-01-23 13:42:17 +01:00
|
|
|
|
}
|
2004-06-15 22:17:49 +02:00
|
|
|
|
else
|
2004-01-23 13:42:17 +01:00
|
|
|
|
{
|
2004-06-15 22:17:49 +02:00
|
|
|
|
print "connection au serveur ldap <20>chou<6F>e<br>";
|
2004-01-23 13:42:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
|
|
|
|
|
llxFooter();
|
|
|
|
|
|
?>
|