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>
|
2005-07-10 14:37:31 +02:00
|
|
|
|
* Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com>
|
2006-03-31 21:30:08 +02:00
|
|
|
|
* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
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
|
|
|
|
|
2005-07-14 01:00:37 +02:00
|
|
|
|
/**
|
|
|
|
|
|
\file htdocs/admin/ldap.php
|
2004-08-29 14:01:58 +02:00
|
|
|
|
\ingroup ldap
|
|
|
|
|
|
\brief Page d'administration/configuration du module Ldap
|
|
|
|
|
|
\version $Revision$
|
2005-07-14 01:00:37 +02:00
|
|
|
|
\remarks Exemple configuration :
|
2005-07-14 19:32:04 +02:00
|
|
|
|
LDAP_SERVER_HOST Serveur LDAP 192.168.1.50
|
|
|
|
|
|
LDAP_SERVER_PORT Port LDAP 389
|
|
|
|
|
|
LDAP_ADMIN_DN Administrateur LDAP cn=adminldap,dc=societe,dc=com
|
|
|
|
|
|
LDAP_ADMIN_PASS Mot de passe xxxxxxxx
|
|
|
|
|
|
LDAP_USER_DN DN des utilisateurs ou=users,dc=societe,dc=com
|
|
|
|
|
|
LDAP_GROUP_DN DN des groupes ou=groups,dc=societe,dc=com
|
|
|
|
|
|
LDAP_CONTACT_DN DN des contacts ou=contacts,dc=societe,dc=com
|
|
|
|
|
|
LDAP_SERVER_TYPE Type Openldap
|
2004-08-29 14:01:58 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
2004-01-23 13:42:17 +01:00
|
|
|
|
require("./pre.inc.php");
|
2006-06-24 17:13:29 +02:00
|
|
|
|
require_once(DOL_DOCUMENT_ROOT."/lib/authldap.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)
|
|
|
|
|
|
{
|
2006-03-31 21:30:08 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_SERVER_TYPE',$_POST["type"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION',$_POST["version"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST',$_POST["host"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-06-24 17:13:29 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE',$_POST["slave"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-03-31 21:30:08 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_SERVER_PORT',$_POST["port"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-06-24 17:13:29 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_SERVER_DN',$_POST["dn"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-03-31 21:30:08 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_ADMIN_DN',$_POST["admin"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_ADMIN_PASS',$_POST["pass"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_USER_DN',$_POST["user"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_GROUP_DN',$_POST["group"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE',$_POST["activecontact"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-06-24 20:51:18 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE',$_POST["activesynchro"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-03-31 21:30:08 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN',$_POST["contact"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-06-12 18:42:46 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS',$_POST["usetls"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-06-24 20:51:18 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN',$_POST["fieldlogin"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-06-12 18:42:46 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME',$_POST["fieldname"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-06-24 20:51:18 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME',$_POST["fieldfirstname"]))
|
2006-06-12 18:42:46 +02:00
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL',$_POST["fieldmail"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',$_POST["fieldphone"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-06-24 20:51:18 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',$_POST["fieldfax"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
|
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',$_POST["fieldmobile"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-06-12 18:42:46 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION',$_POST["filterconnection"]))
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-06-24 20:51:18 +02:00
|
|
|
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA',$_POST["fieldloginsamba"]))
|
2006-06-12 18:42:46 +02:00
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2006-03-31 21:30:08 +02:00
|
|
|
|
if ($db->query($sql))
|
2004-01-23 13:42:17 +01:00
|
|
|
|
{
|
2006-03-31 21:30:08 +02:00
|
|
|
|
Header("Location: ldap.php");
|
|
|
|
|
|
exit;
|
2004-01-23 13:42:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
2005-07-10 15:30:57 +02:00
|
|
|
|
/*
|
|
|
|
|
|
* Visu
|
|
|
|
|
|
*/
|
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
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
// Test si fonction LDAP actives
|
|
|
|
|
|
if (! function_exists("ldap_connect"))
|
2005-08-08 14:13:41 +02:00
|
|
|
|
{
|
2006-03-31 21:30:08 +02:00
|
|
|
|
$mesg=$langs->trans("LDAPFunctionsNotAvailableOnPHP");
|
2005-08-08 14:13:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
if ($mesg) print '<div class="error">'.$mesg.'</div>';
|
2006-03-31 23:29:15 +02:00
|
|
|
|
else print '<br>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
|
2005-07-10 15:30:57 +02:00
|
|
|
|
|
2004-01-23 13:42:17 +01:00
|
|
|
|
print '<form method="post" action="ldap.php?action=setvalue">';
|
|
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<table class="noborder" width="100%">';
|
2005-01-16 18:00:11 +01:00
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
|
print '<td>'.$langs->trans("Parameter").'</td>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<td>'.$langs->trans("Value").'</td>';
|
|
|
|
|
|
print '<td>'.$langs->trans("Example").'</td>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
print "</tr>\n";
|
2006-03-31 21:30:08 +02:00
|
|
|
|
|
|
|
|
|
|
$var=true;
|
|
|
|
|
|
$html=new Form($db);
|
|
|
|
|
|
|
|
|
|
|
|
// Type
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("Type").'</td><td>';
|
|
|
|
|
|
$arraylist=array();
|
|
|
|
|
|
$arraylist['activedirectory']='Active Directory';
|
|
|
|
|
|
$arraylist['openldap']='OpenLdap';
|
|
|
|
|
|
$arraylist['egroupware']='Egroupware';
|
|
|
|
|
|
$html->select_array('type',$arraylist,$conf->global->LDAP_SERVER_TYPE);
|
|
|
|
|
|
print '</td><td> </td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
// Version
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("Version").'</td><td>';
|
|
|
|
|
|
$arraylist=array();
|
|
|
|
|
|
$arraylist['3']='Version 3';
|
|
|
|
|
|
$arraylist['2']='Version 2';
|
|
|
|
|
|
$html->select_array('version',$arraylist,$conf->global->LDAP_SERVER_PROTOCOLVERSION);
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '</td><td>'.$langs->trans("LDAPServerProtocolVersion").'</td></tr>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
|
2006-06-24 20:51:18 +02:00
|
|
|
|
// Serveur primaire
|
2006-03-31 21:30:08 +02:00
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>';
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print $langs->trans("LDAPPrimaryServer").'</td><td>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<input size="25" type="text" name="host" value="'.$conf->global->LDAP_SERVER_HOST.'">';
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPServerExample").'</td></tr>';
|
|
|
|
|
|
|
2006-06-24 20:51:18 +02:00
|
|
|
|
// Serveur secondaire
|
2006-06-24 17:13:29 +02:00
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>';
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print $langs->trans("LDAPSecondaryServer").'</td><td>';
|
2006-06-24 17:13:29 +02:00
|
|
|
|
print '<input size="25" type="text" name="slave" value="'.$conf->global->LDAP_SERVER_HOST_SLAVE.'">';
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPServerExample").'</td></tr>';
|
|
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
// Port
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPServerPort").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_SERVER_PORT)
|
2005-07-13 11:22:59 +02:00
|
|
|
|
{
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<input size="25" type="text" name="port" value="'.$conf->global->LDAP_SERVER_PORT.'">';
|
2005-07-13 11:22:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2005-08-08 14:13:41 +02:00
|
|
|
|
print '<input size="25" type="text" name="port" value="389">';
|
2005-07-13 11:22:59 +02:00
|
|
|
|
}
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '</td><td>'.$langs->trans("LDAPServerPortExample").'</td></tr>';
|
|
|
|
|
|
|
2006-06-24 17:13:29 +02:00
|
|
|
|
// DNserver
|
|
|
|
|
|
$var=!$var;
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPServerDn").'</td><td>';
|
2006-06-24 17:13:29 +02:00
|
|
|
|
print '<input size="25" type="text" name="dn" value="'.$conf->global->LDAP_SERVER_DN.'">';
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPServerDnExample").'</td></tr>';
|
|
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
// DNAdmin
|
|
|
|
|
|
$var=!$var;
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPAdminDn").'</td><td>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<input size="25" type="text" name="admin" value="'.$conf->global->LDAP_ADMIN_DN.'">';
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '</td><td>'.$langs->trans("LDAPAdminDnExample").'</td></tr>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
|
|
|
|
|
|
// Pass
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPPassword").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_ADMIN_PASS)
|
2005-07-12 13:28:44 +02:00
|
|
|
|
{
|
2006-06-24 17:13:29 +02:00
|
|
|
|
print '<input size="25" type="password" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">';// je le met en visible pour test
|
2005-07-12 13:28:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<input size="25" type="text" name="pass" value="'.$conf->global->LDAP_ADMIN_PASS.'">';
|
2005-07-12 13:28:44 +02:00
|
|
|
|
}
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '</td><td> </td></tr>';
|
2004-06-15 20:13:55 +02:00
|
|
|
|
|
2006-06-12 18:42:46 +02:00
|
|
|
|
// Utiliser TLS
|
|
|
|
|
|
$var=!$var;
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPServerUseTLS").'</td><td>';
|
2006-06-12 18:42:46 +02:00
|
|
|
|
$arraylist=array();
|
|
|
|
|
|
$arraylist['0']=$langs->trans("No");
|
|
|
|
|
|
$arraylist['1']=$langs->trans("Yes");
|
|
|
|
|
|
$html->select_array('usetls',$arraylist,$conf->global->LDAP_SERVER_USE_TLS);
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPServerUseTLSExample").'</td></tr>';
|
|
|
|
|
|
|
2005-08-08 14:13:41 +02:00
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
|
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsersAndGroup").'</td>';
|
|
|
|
|
|
print "</tr>\n";
|
2005-08-08 14:13:41 +02:00
|
|
|
|
|
2006-06-12 18:42:46 +02:00
|
|
|
|
// Synchro utilisateurs/groupes active
|
2006-03-31 21:30:08 +02:00
|
|
|
|
$var=!$var;
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPDnSynchroActive").'</td><td>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
$arraylist=array();
|
2006-06-12 18:42:46 +02:00
|
|
|
|
$arraylist['0']=$langs->trans("No");
|
2006-06-24 20:51:18 +02:00
|
|
|
|
$arraylist['ldap2dolibarr']=$langs->trans("LDAPToDolibarr");
|
|
|
|
|
|
$arraylist['dolibarr2ldap']=$langs->trans("DolibarrToLDAP");
|
|
|
|
|
|
$html->select_array('activesynchro',$arraylist,$conf->global->LDAP_SYNCHRO_ACTIVE);
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPDnSynchroActiveExample").'</td></tr>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
// DN Pour les utilisateurs
|
|
|
|
|
|
$var=!$var;
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPUserDn").'</td><td>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<input size="25" type="text" name="user" value="'.$conf->global->LDAP_USER_DN.'">';
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '</td><td>'.$langs->trans("LDAPUserDnExample").'</td></tr>';
|
2004-01-23 13:42:17 +01:00
|
|
|
|
|
2006-06-12 18:42:46 +02:00
|
|
|
|
// Champ de login
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLogin").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_FIELD_LOGIN)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_FIELD_LOGIN.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldlogin" value="uid">';
|
|
|
|
|
|
}
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
// Filtre de connexion
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_FILTER_CONNECTION)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="filterconnection" value="'.$conf->global->LDAP_FILTER_CONNECTION.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2006-06-24 17:13:29 +02:00
|
|
|
|
print '<input size="25" type="text" name="filterconnection" value="&(objectClass=user)(objectCategory=person)">';
|
2006-06-12 18:42:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td></tr>';
|
|
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
// DN pour les groupes
|
|
|
|
|
|
$var=!$var;
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPGroupDn").'</td><td>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<input size="25" type="text" name="group" value="'.$conf->global->LDAP_GROUP_DN.'">';
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '</td><td>'.$langs->trans("LDAPGroupDnExample").'</td></tr>';
|
2005-01-16 18:00:11 +01:00
|
|
|
|
|
2004-01-23 13:42:17 +01:00
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
|
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeContacts").'</td>';
|
|
|
|
|
|
print "</tr>\n";
|
2005-08-08 14:13:41 +02:00
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
// Synchro contact active
|
|
|
|
|
|
$var=!$var;
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPDnContactActive").'</td><td>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
$arraylist=array();
|
|
|
|
|
|
$arraylist['0']=$langs->trans("No");
|
|
|
|
|
|
$arraylist['1']=$langs->trans("Yes");
|
|
|
|
|
|
$html->select_array('activecontact',$arraylist,$conf->global->LDAP_CONTACT_ACTIVE);
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '</td><td>'.$langs->trans("LDAPDnContactActiveExample").'</td></tr>';
|
2005-08-08 14:13:41 +02:00
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
// DN Pour les contacts
|
|
|
|
|
|
$var=!$var;
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPContactDn").'</td><td>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print '<input size="25" type="text" name="contact" value="'.$conf->global->LDAP_CONTACT_DN.'">';
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '</td><td>'.$langs->trans("LDAPContactDnExample").'</td></tr>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
|
2006-06-12 18:42:46 +02:00
|
|
|
|
print '<tr class="liste_titre">';
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<td colspan="3">'.$langs->trans("LDAPAttributes").'</td>';
|
2006-06-12 18:42:46 +02:00
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
2006-06-24 20:51:18 +02:00
|
|
|
|
// Login
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_FIELD_LOGIN_SAMBA)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_FIELD_LOGIN_SAMBA.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldloginsamba" value="samaccountname">';
|
|
|
|
|
|
}
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
// Name
|
2006-06-12 18:42:46 +02:00
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_FIELD_NAME)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_FIELD_NAME.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<input size="25" type="text" name="fieldname" value="sn">';
|
2006-06-12 18:42:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td></tr>';
|
|
|
|
|
|
|
2006-06-24 20:51:18 +02:00
|
|
|
|
// Firstname
|
2006-06-12 18:42:46 +02:00
|
|
|
|
$var=!$var;
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_FIELD_FIRSTNAME)
|
2006-06-12 18:42:46 +02:00
|
|
|
|
{
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'">';
|
2006-06-12 18:42:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '<input size="25" type="text" name="fieldfirstname" value="givenname">';
|
2006-06-12 18:42:46 +02:00
|
|
|
|
}
|
2006-06-24 20:51:18 +02:00
|
|
|
|
print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td></tr>';
|
2006-06-12 18:42:46 +02:00
|
|
|
|
|
|
|
|
|
|
// Mail
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_FIELD_MAIL)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_FIELD_MAIL.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldmail" value="mail">';
|
|
|
|
|
|
}
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
// Phone
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_FIELD_PHONE)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldphone" value="telephonenumber">';
|
|
|
|
|
|
}
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td></tr>';
|
|
|
|
|
|
|
2006-06-24 20:51:18 +02:00
|
|
|
|
// Fax
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_FIELD_FAX)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldfax" value="facsimiletelephonenumber">';
|
|
|
|
|
|
}
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
// Mobile
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
|
|
|
|
|
|
if ($conf->global->LDAP_FIELD_MOBILE)
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<input size="25" type="text" name="fieldmobile" value="mobile">';
|
|
|
|
|
|
}
|
|
|
|
|
|
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td></tr>';
|
|
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
|
|
|
|
|
|
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
|
|
|
|
|
|
print '</table>';
|
|
|
|
|
|
|
|
|
|
|
|
print '</form>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
* Test de la connexion
|
|
|
|
|
|
*/
|
|
|
|
|
|
if (function_exists("ldap_connect"))
|
|
|
|
|
|
{
|
|
|
|
|
|
if ($conf->global->LDAP_SERVER_HOST)
|
|
|
|
|
|
{
|
2006-03-31 23:29:15 +02:00
|
|
|
|
print '<a class="tabAction" href="ldap.php?action=test">'.$langs->trans("LDAPTestConnect").'</a><br><br>';
|
2006-03-31 21:30:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($conf->global->LDAP_SERVER_HOST && $conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS && $_GET["action"] == 'test')
|
|
|
|
|
|
{
|
2006-06-24 17:13:29 +02:00
|
|
|
|
$ldap = New AuthLdap();
|
2006-03-31 21:30:08 +02:00
|
|
|
|
// Test ldap_connect
|
2006-06-12 16:55:44 +02:00
|
|
|
|
// ce test n'est pas fiable car une ressource est constamment retourn<72>e
|
|
|
|
|
|
// il faut se fier au test ldap_bind
|
2006-06-24 17:13:29 +02:00
|
|
|
|
$ds = $ldap->connect();
|
2006-03-31 21:30:08 +02:00
|
|
|
|
if ($ds)
|
|
|
|
|
|
{
|
|
|
|
|
|
print img_picto('','info');
|
|
|
|
|
|
print $langs->trans("LDAPTestOK").'<br>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print img_picto('','alerte');
|
|
|
|
|
|
print $langs->trans("LDAPTestKO").'<br>';
|
|
|
|
|
|
print "<br>";
|
2006-06-24 17:13:29 +02:00
|
|
|
|
print $ldap->ldapErrorCode." - ".$ldap->ldapErrorText;
|
2006-03-31 21:30:08 +02:00
|
|
|
|
print "<br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2006-06-12 14:55:04 +02:00
|
|
|
|
if ($ds)
|
2006-03-31 21:30:08 +02:00
|
|
|
|
{
|
2006-06-12 15:14:02 +02:00
|
|
|
|
// Test ldap_getversion
|
2006-06-24 17:13:29 +02:00
|
|
|
|
if (($ldap->getVersion() == 3))
|
2006-06-12 14:55:04 +02:00
|
|
|
|
{
|
|
|
|
|
|
print img_picto('','info');
|
|
|
|
|
|
print $langs->trans("LDAPSetupForVersion3").'<br>';
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print img_picto('','info');
|
|
|
|
|
|
print $langs->trans("LDAPSetupForVersion2").'<br>';
|
|
|
|
|
|
}
|
2006-03-31 21:30:08 +02:00
|
|
|
|
|
2006-06-12 15:14:02 +02:00
|
|
|
|
// Test ldap_bind
|
2006-06-24 17:13:29 +02:00
|
|
|
|
$bind = $ldap->bind();
|
2006-06-12 15:14:02 +02:00
|
|
|
|
|
|
|
|
|
|
if ($bind)
|
|
|
|
|
|
{
|
|
|
|
|
|
print img_picto('','info');
|
|
|
|
|
|
print "Connexion au dn $dn r<>ussi<br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print img_picto('','alerte');
|
|
|
|
|
|
print "Connexion au dn $dn rat<61> : ";
|
2006-06-24 17:13:29 +02:00
|
|
|
|
print $ldap->ldapErrorCode." - ".$ldap->ldapErrorText;
|
2006-06-12 15:14:02 +02:00
|
|
|
|
print "<br>";
|
|
|
|
|
|
}
|
2006-03-31 21:30:08 +02:00
|
|
|
|
|
2006-06-12 15:14:02 +02:00
|
|
|
|
// Test ldap_unbind
|
2006-06-24 17:13:29 +02:00
|
|
|
|
$unbind = $ldap->unbind();
|
2006-06-12 15:14:02 +02:00
|
|
|
|
|
2006-06-24 17:13:29 +02:00
|
|
|
|
if ($unbind)
|
2006-06-12 15:14:02 +02:00
|
|
|
|
{
|
|
|
|
|
|
print img_picto('','info');
|
|
|
|
|
|
print "D<EFBFBD>connection du dn $dn r<>ussi<br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print img_picto('','alerte');
|
|
|
|
|
|
print "D<EFBFBD>connection du dn $dn rat<61>";
|
|
|
|
|
|
print "<br>";
|
2006-06-24 17:13:29 +02:00
|
|
|
|
print $ldap->ldapErrorCode." - ".$ldap->ldapErrorText;
|
2006-06-12 15:14:02 +02:00
|
|
|
|
}
|
2006-03-31 21:30:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2004-01-23 13:42:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$db->close();
|
|
|
|
|
|
|
2006-03-31 21:30:08 +02:00
|
|
|
|
llxFooter('$Date$ - $Revision$');
|
|
|
|
|
|
|
2004-01-23 13:42:17 +01:00
|
|
|
|
?>
|