* Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005 Regis Houssin * * 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$ \remarks Exemple configuration : 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 */ require("./pre.inc.php"); require_once(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_PORT';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_SERVER_PORT','".$_POST["port"]."',0);"; $db->query($sql); //suppression pour compatibilité divers config ldap // //$sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SUFFIX_DN';"; //$db->query($sql); //$sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES //('LDAP_SUFFIX_DN','".$_POST["suffix"]."',0);"; //$db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_ADMIN_DN';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_ADMIN_DN','".$_POST["admin"]."',0);"; $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_ADMIN_PASS';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_ADMIN_PASS','".$_POST["pass"]."',0);"; $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_USER_DN';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_USER_DN','".$_POST["user"]."',0);"; $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_GROUP_DN';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_GROUP_DN','".$_POST["group"]."',0);"; $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_CONTACT_ACTIVE';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_CONTACT_ACTIVE','".$_POST["activecontact"]."',0);"; $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_CONTACT_DN';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_CONTACT_DN','".$_POST["contact"]."',0);"; $db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'LDAP_SERVER_PROTOCOLVERSION';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('LDAP_SERVER_PROTOCOLVERSION','".$_POST["version"]."',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"); } } /* * Visu */ llxHeader(); print_titre($langs->trans("LDAPSetup")); print '
'; print ''; print ''; print '
'; print ''; print ''; print ''; print ''; print "\n"; if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST) { print ''; } else { print ''; } if (defined("LDAP_SERVER_PORT") && LDAP_SERVER_PORT) { print ''; } else { print ''; } //suppression pour compatibilité divers config ldap // //if (defined("LDAP_SUFFIX_DN") && LDAP_SUFFIX_DN) //{ // print ''; //} //else //{ // print ''; //} if (defined("LDAP_ADMIN_DN") && LDAP_ADMIN_DN) { print ''; } else { print ''; } if (defined("LDAP_ADMIN_PASS") && LDAP_ADMIN_PASS) { print ''; } else { print ''; } if (defined("LDAP_USER_DN") && LDAP_USER_DN) { print ''; } else { print ''; } if (defined("LDAP_GROUP_DN") && LDAP_GROUP_DN) { print ''; } else { print ''; } if (defined("LDAP_CONTACT_ACTIVE") && LDAP_CONTACT_ACTIVE) { print ''; } else { print ''; } if (defined("LDAP_CONTACT_DN") && LDAP_CONTACT_DN) { print ''; } else { print ''; } if (defined("LDAP_SERVER_TYPE") && LDAP_SERVER_TYPE) { print ''; } else { print ''; } print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'.$langs->trans("LDAPServer").''.LDAP_SERVER_HOST.'
'.$langs->trans("LDAPServer").''.$langs->trans("LDAPServerExample").'
'.$langs->trans("LDAPServerPort").''.LDAP_SERVER_PORT.'
'.$langs->trans("LDAPServerPort").''.$langs->trans("LDAPServerPortExample").'
'.$langs->trans("LDAPSuffix").''.LDAP_SUFFIX_DN.'
'.$langs->trans("LDAPSuffix").''.$langs->trans("LDAPSuffixExample").'
'.$langs->trans("DNAdmin").''.LDAP_ADMIN_DN.'
'.$langs->trans("DNAdmin").''.$langs->trans("DNAdminExample").'
'.$langs->trans("LDAPPassword").'********
'.$langs->trans("LDAPPassword").''.$langs->trans("LDAPPasswordExample").'
'.$langs->trans("DNUser").''.LDAP_USER_DN.'
'.$langs->trans("DNUser").''.$langs->trans("DNUserExample").'
'.$langs->trans("DNGroup").''.LDAP_GROUP_DN.'
'.$langs->trans("DNGroup").''.$langs->trans("DNGroupExample").'
'.$langs->trans("DNContactActive").''.$langs->trans("DNContactActiveYes").'
'.$langs->trans("DNContactActive").''.$langs->trans("DNContactActiveExample").'
'.$langs->trans("DNContact").''.LDAP_CONTACT_DN.'
'.$langs->trans("DNContact").''.$langs->trans("DNContactExample").'
'.$langs->trans("Type").''.LDAP_SERVER_TYPE.'
'.$langs->trans("Type").''.$langs->trans("TypeExample").'
'.$langs->trans("Version").''.LDAP_SERVER_PROTOCOLVERSION.'
'; print '
'; /* * Modification */ print '
'; print ''; print ''; print ''; print ''; print "\n"; print ''; print ''; //suppression pour compatibilité divers config ldap // //print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Parameter").''.$langs->trans("Value").' 
'; print $langs->trans("LDAPServer").''; print ''; print '
'.$langs->trans("LDAPServerPort").''; if (defined("LDAP_SERVER_PORT") && LDAP_SERVER_PORT) { print ''; } else { print ''; } print '
'.$langs->trans("LDAPSuffix").''; //print ''; //print '
'.$langs->trans("DNAdmin").''; print ''; print '
'.$langs->trans("LDAPPassword").''; if (defined("LDAP_ADMIN_PASS") && LDAP_ADMIN_PASS) { print ''; } else { print ''; } print '
'.$langs->trans("DNUser").''; print ''; print '
'.$langs->trans("DNGroup").''; print ''; print '
'.$langs->trans("DNContactActive").''; print '
'.$langs->trans("DNContact").''; print ''; print '
'.$langs->trans("Type").''; print '
'.$langs->trans("Version").''; print '
'; print '
'; /* * test de la connexion */ if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST) { print ''.$langs->trans("TestConnectLdap").'

'; } if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && LDAP_ADMIN_DN && LDAP_ADMIN_PASS && $_GET["action"] == 'test') { $ds = dolibarr_ldap_connect(); if ($ds) { print img_picto('','info'); print "connexion au serveur ldap réussie
"; } else { print img_picto('','alerte'); print "connexion au serveur ldap échouée"; print "
"; print ldap_error($ds); print "
"; } if ((dolibarr_ldap_getversion($ds) == 3)) { print img_picto('','info'); print "Serveur ldap configuré en version 3
"; } else { print img_picto('','info'); print "Serveur ldap configuré en version 2
"; } $bind = @dolibarr_ldap_bind($ds); if ($bind) { print img_picto('','info'); print "connexion au dn $dn réussi
"; } else { print img_picto('','alerte'); print "connexion au dn $dn raté : "; print ldap_error($ds); print "
"; } $unbind = @dolibarr_ldap_unbind($ds); if ($bind) { print img_picto('','info'); print "déconnection du dn $dn réussi
"; } else { print img_picto('','alerte'); print "déconnection du dn $dn raté"; print "
"; } } $db->close(); llxFooter(); ?>