Amlioration config module LDAP. On peut choisir quel est le champ qui sert de cl LDAP.

This commit is contained in:
Laurent Destailleur 2006-11-20 01:13:13 +00:00
parent d738f9324f
commit 0f01c13153
27 changed files with 978 additions and 532 deletions

View File

@ -517,8 +517,9 @@ class Adherent
/**
\brief fonction qui récupére l'adhérent en donnant son rowid
\param rowid
\brief Fonction qui récupére l'adhérent en donnant son rowid
\param rowid
\return int <0 si KO, >0 si OK
*/
function fetch($rowid)
{
@ -531,13 +532,14 @@ class Adherent
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t, ".MAIN_DB_PREFIX."adherent as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_pays as p ON d.pays = p.rowid";
$sql.= " WHERE d.rowid = ".$rowid." AND d.fk_adherent_type = t.rowid";
$result=$this->db->query( $sql);
if ($result)
dolibarr_syslog("Adherent.class::fetch sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($result))
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($result);
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->statut = $obj->statut;
@ -568,12 +570,13 @@ class Adherent
$this->type = $obj->type;
$this->need_subscription = ($obj->cotisation=='yes'?1:0);
}
return 1;
}
else
{
dolibarr_print_error($this->db);
$this->error=$this->db->error();
return -1;
}
}

View File

@ -159,39 +159,43 @@ class AdherentType
}
/**
\brief fonction qui permet de récupérer le status de l'adhérent
\param rowid
*/
\brief Fonction qui permet de récupérer le status de l'adhérent
\param rowid
\return int <0 si KO, >0 si OK
*/
function fetch($rowid)
{
$sql = "SELECT d.rowid, d.libelle, d.statut, d.cotisation, d.mail_valid, d.note, d.vote";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.rowid = $rowid";
if ( $this->db->query( $sql) )
{
if ($this->db->num_rows())
{
$obj = $this->db->fetch_object();
$this->id = $obj->rowid;
$this->libelle = $obj->libelle;
$this->statut = $obj->statut;
$this->cotisation = $obj->cotisation;
$this->mail_valid = $obj->mail_valid;
$this->commentaire = $obj->note;
$this->vote = $obj->vote;
}
}
else
{
print $this->db->error();
}
{
$sql = "SELECT d.rowid, d.libelle, d.statut, d.cotisation, d.mail_valid, d.note, d.vote";
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
$sql .= " WHERE d.rowid = ".$rowid;
dolibarr_syslog("Adherent_type::fetch sql=".$sql);
}
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
$this->libelle = $obj->libelle;
$this->statut = $obj->statut;
$this->cotisation = $obj->cotisation;
$this->mail_valid = $obj->mail_valid;
$this->commentaire = $obj->note;
$this->vote = $obj->vote;
}
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
function liste_array()
function liste_array()
{
$projets = array();

View File

@ -29,6 +29,7 @@
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php");
@ -557,13 +558,21 @@ if ($action == 'create')
print '<table class="border" width="100%">';
// Nom
print '<tr><td>'.$langs->trans("Lastname").'*</td><td><input type="text" name="nom" value="'.$adh->nom.'" size="40"></td>';
print '<td width="50%" valign="top">'.$langs->trans("Comments").' :</td></tr>';
// Prenom
print '<tr><td>'.$langs->trans("Firstname").'*</td><td><input type="text" name="prenom" size="40" value="'.$adh->prenom.'"></td>';
$rowspan=12;
print '<td valign="top" rowspan="'.$rowspan.'"><textarea name="comment" wrap="soft" cols="60" rows="12"></textarea></td></tr>';
// Login
print '<tr><td>'.$langs->trans("Login").'*</td><td><input type="text" name="member_login" size="40" value="'.$adh->login.'"></td></tr>';
// Mot de pass
print '<tr><td>'.$langs->trans("Password").'*</td><td><input type="password" name="member_pass" size="40" value="'.$adh->password.'"></td></tr>';
// Type
print '<tr><td width="15%">'.$langs->trans("MemberType").'*</td><td width="35%">';
$listetype=$adht->liste_array();
@ -583,15 +592,21 @@ if ($action == 'create')
print "</td>\n";
print '<tr><td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.$adh->societe.'"></td></tr>';
// Adresse
print '<tr><td valign="top">'.$langs->trans("Address").'</td><td>';
print '<textarea name="adresse" wrap="soft" cols="40" rows="2"></textarea></td></tr>';
// CP
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td><input type="text" name="cp" size="8"> <input type="text" name="ville" size="32" value="'.$adh->ville.'"></td></tr>';
// Ville
print '<tr><td>'.$langs->trans("Country").'</td><td>';
$htmls->select_pays($adh->pays_code?$adh->pays_code:$mysoc->pays_code,'pays_code');
print '</td></tr>';
// EMail
print '<tr><td>'.$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'*':'').'</td><td><input type="text" name="member_email" size="40" value="'.$adh->email.'"></td></tr>';
print '<tr><td>'.$langs->trans("Login").'*</td><td><input type="text" name="member_login" size="40" value="'.$adh->login.'"></td></tr>';
print '<tr><td>'.$langs->trans("Password").'*</td><td><input type="password" name="member_pass" size="40" value="'.$adh->password.'"></td></tr>';
// Date naissance
print "<tr><td>".$langs->trans("Birthday")."</td><td>\n";
@ -659,17 +674,13 @@ if ($rowid && $action != 'edit')
$html = new Form($db);
/*
* Affichage onglets
*/
$h = 0;
/*
* Affichage onglets
*/
$head = member_prepare_head($adh);
$head[$h][0] = DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$rowid;
$head[$h][1] = $langs->trans("Card");
$hselected=$h;
$h++;
dolibarr_fiche_head($head, 'general', $langs->trans("Member").": ".$adh->fullname);
dolibarr_fiche_head($head, $hselected, $langs->trans("MemberCard"));
// Confirmation de la suppression de l'adhérent
if ($action == 'delete')
@ -737,19 +748,26 @@ if ($rowid && $action != 'edit')
}
print '<table class="border" width="100%">';
print '<form action="fiche.php" method="post">';
print '<table class="border" width="100%">';
// Ref
print '<tr><td>'.$langs->trans("Ref").'</td><td class="valeur" colspan="3">'.$adh->id.'&nbsp;</td></tr>';
// Nom
print '<tr><td>'.$langs->trans("Lastname").'*</td><td class="valeur">'.$adh->nom.'&nbsp;</td>';
print '<td valign="top" width="50%">'.$langs->trans("Comments").'</td></tr>';
// Prenom
print '<tr><td width="15%">'.$langs->trans("Firstname").'*</td><td class="valeur" width="35%">'.$adh->prenom.'&nbsp;</td>';
print '<td rowspan="'.(13+count($adh->array_options)).'" valign="top" width="50%">';
print nl2br($adh->commentaire).'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Type").'*</td><td class="valeur">'.$adh->type."</td></tr>\n";
// Login
print '<tr><td>'.$langs->trans("Login").'*</td><td class="valeur">'.$adh->login.'&nbsp;</td></tr>';
// Type
print '<tr><td>'.$langs->trans("Type").'*</td><td class="valeur">'.$adh->type."</td></tr>\n";
print '<tr><td>'.$langs->trans("Person").'</td><td class="valeur">'.$adh->getmorphylib().'</td></tr>';
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$adh->societe.'&nbsp;</td></tr>';
@ -757,7 +775,6 @@ if ($rowid && $action != 'edit')
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td class="valeur">'.$adh->cp.' '.$adh->ville.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Country").'</td><td class="valeur">'.$adh->pays.'</td></tr>';
print '<tr><td>'.$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'*':'').'</td><td class="valeur">'.$adh->email.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Login").'*</td><td class="valeur">'.$adh->login.'&nbsp;</td></tr>';
// print '<tr><td>Pass</td><td class="valeur">'.$adh->pass.'&nbsp;</td></tr>';
print '<tr><td>'.$langs->trans("Birthday").'</td><td class="valeur">'.$adh->naiss.'&nbsp;</td></tr>';
print '<tr><td>URL Photo</td><td class="valeur">'.$adh->photo.'&nbsp;</td></tr>';
@ -771,8 +788,8 @@ if ($rowid && $action != 'edit')
print "<tr><td>$value</td><td>".$adh->array_options["options_$key"]."&nbsp;</td></tr>\n";
}
print '</form>';
print "</table>\n";
print '</form>';
print "</div>\n";
@ -907,13 +924,14 @@ if ($rowid && $action != 'edit')
*/
if ($user->rights->adherent->cotisation->creer)
{
print "\n\n<!-- Form add subscription -->\n";
print '<form name="cotisation" method="post" action="'.$_SERVER["PHP_SELF"].'">';
print "<table class=\"border\" width=\"100%\">\n";
print '<form name="cotisation" method="post" action="fiche.php">';
print '<tr><td width="15%">'.$langs->trans("SubscriptionEndDate");
print '<input type="hidden" name="action" value="cotisation">';
print '<input type="hidden" name="rowid" value="'.$rowid.'">';
print '<tr><td width="15%">'.$langs->trans("SubscriptionEndDate").'</td>';
print '</td>';
print '<td width="35%">';
if ($adh->datefin)
{
@ -968,10 +986,11 @@ if ($rowid && $action != 'edit')
print strftime("%Y",($adh->datefin?$adh->datefin:time())).'" ></td></tr>';
}
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"</td></tr>';
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>';
print '</form>';
print '</table>';
print '</form>';
print "\n<!-- End form subscription -->\n\n";
}
print '</td></tr>';

200
htdocs/adherents/ldap.php Normal file
View File

@ -0,0 +1,200 @@
<?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Regis Houssin <regis.houssin@cap-networks.com>
*
* 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/adherents/ldap.php
\ingroup ldap
\brief Page fiche LDAP adherent
\version $Revision$
*/
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
$user->getrights('commercial');
$langs->load("companies");
$langs->load("members");
$langs->load("ldap");
// Protection quand utilisateur externe
$rowid = isset($_GET["id"])?$_GET["id"]:'';
$socid=0;
if ($user->societe_id > 0)
{
$socid = $user->societe_id;
}
/*
* Affichage page
*/
llxHeader();
$form = new Form($db);
$adh = new Adherent($db);
$adh->id = $rowid;
$result=$adh->fetch($rowid);
if (! $result)
{
dolibarr_print_error($db,"Failed to get adherent: ".$adh->error);
exit;
}
$adh->fetch_optionals($rowid);
$adht = new AdherentType($db);
$result=$adht->fetch($adh->typeid);
if (! $result)
{
dolibarr_print_error($db,"Failed to get type of adherent: ".$adht->error);
exit;
}
/*
* Affichage onglets
*/
$head = member_prepare_head($adh);
dolibarr_fiche_head($head, 'ldap', $langs->trans("Member").": ".$adh->fullname);
/*
* Fiche en mode visu
*/
print '<table class="border" width="100%">';
// Ref
print '<tr><td>'.$langs->trans("Ref").'</td><td class="valeur">'.$adh->id.'&nbsp;</td></tr>';
// Nom
print '<tr><td>'.$langs->trans("Lastname").'*</td><td class="valeur">'.$adh->nom.'&nbsp;</td>';
print '</tr>';
// Prenom
print '<tr><td width="15%">'.$langs->trans("Firstname").'*</td><td class="valeur">'.$adh->prenom.'&nbsp;</td>';
print '</tr>';
// Login
print '<tr><td>'.$langs->trans("Login").'*</td><td class="valeur">'.$adh->login.'&nbsp;</td></tr>';
// Type
print '<tr><td>'.$langs->trans("Type").'*</td><td class="valeur">'.$adh->type."</td></tr>\n";
// LDAP DN
$langs->load("admin");
print '<tr><td>'.$langs->trans("LDAPMemberDn").'*</td><td class="valeur">'.$conf->global->LDAP_MEMBER_DN."</td></tr>\n";
// LDAP Server
print '<tr><td>'.$langs->trans("LDAPPrimaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
print '<tr><td>'.$langs->trans("LDAPSecondaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
print '<tr><td>'.$langs->trans("LDAPServerPort").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
print '</table>';
print '</div>';
print '<br>';
print_titre($langs->trans("LDAPInformationsForThisMember"));
// Affichage attributs LDAP
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("LDAPAttributes").'</td>';
print '<td>'.$langs->trans("Value").'</td>';
print '</tr>';
// Lecture LDAP
$ldap=new AuthLdap();
$result=$ldap->connect();
if ($result)
{
$bind='';
if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS)
{
dolibarr_syslog("ldap.php: authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
}
if (! $bind) // Si pas de login ou si connexion avec login en echec, on tente en anonyme
{
dolibarr_syslog("ldap.php: bind",LOG_DEBUG);
$bind=$ldap->bind();
}
if ($bind)
{
$info["cn"] = trim($adh->prenom." ".$adh->nom);
$info["uid"] = trim($adh->login);
$dn = $conf->global->LDAP_MEMBER_DN;
// $dn = "cn=".$info["cn"].",".$dn;
// $dn = "uid=".$info["uid"].",".$dn
$search = "(cn=".$info["cn"].")";
//$search = "(uid=".$info["uid"].")";
$result=$ldap->search($dn,$search);
// Affichage arbre
if (sizeof($result))
{
$html=new Form($db);
$html->show_ldap_content($result,0,0,true);
}
else
{
print '<tr><td colspan="2">'.$langs->trans("LDAPRecordNotFound").'</td></tr>';
}
$ldap->unbind();
}
else
{
dolibarr_print_error('',$ldap->error);
}
$ldap->close();
}
else
{
dolibarr_print_error('',$ldap->error);
}
print '</table>';
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -32,6 +32,7 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.lib.php");
$langs->load("admin");
@ -74,8 +75,12 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
llxHeader();
$head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives
if (! function_exists("ldap_connect"))
{
@ -86,36 +91,9 @@ if ($mesg) print '<div class="error">'.$mesg.'</div>';
else print '<br>';
// 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"));
dolibarr_fiche_head($head, 'ldap', $langs->trans("LDAP"));
$var=true;
$html=new Form($db);

View File

@ -32,6 +32,7 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.lib.php");
require_once (DOL_DOCUMENT_ROOT."/contact.class.php");
$langs->load("admin");
@ -47,7 +48,10 @@ if (!$user->admin)
if ($_GET["action"] == 'setvalue' && $user->admin)
{
$error=0;
if (! dolibarr_set_const($db, 'LDAP_KEY_CONTACTS',$_POST["key"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN',$_POST["contactdn"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',$_POST["fieldfullname"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME',$_POST["fieldname"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME',$_POST["fieldfirstname"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL',$_POST["fieldmail"])) $error++;
@ -72,8 +76,11 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
llxHeader();
$head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives
if (! function_exists("ldap_connect"))
{
@ -84,36 +91,8 @@ if ($mesg) print '<div class="error">'.$mesg.'</div>';
else print '<br>';
// Onglets
$h = 0;
dolibarr_fiche_head($head, 'contacts', $langs->trans("LDAP"));
$head[$h][0] = DOL_URL_ROOT."/admin/ldap.php";
$head[$h][1] = $langs->trans("LDAPGlobalParameters");
$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");
$hselected=$h;
$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"));
print $langs->trans("LDAPDescContact").'<br>';
print '<br>';
@ -123,7 +102,8 @@ print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeContacts").'</td>';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n";
$var=true;
@ -133,67 +113,94 @@ $html=new Form($db);
// DN Pour les contacts
$var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPContactDn").picto_required().'</b></td><td>';
print '<input size="38" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.'">';
print '</td><td>'.$langs->trans("LDAPContactDnExample").'</td></tr>';
print '<input size="48" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.'">';
print '</td><td>'.$langs->trans("LDAPContactDnExample").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
// Common name
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_FIELD_FULLNAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_FULLNAME.'"'.($conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_FIELD_FULLNAME?' checked="true"':'')."></td>";
print '</tr>';
// Name
$var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPFieldName").picto_required().'</b></td><td>';
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_FIELD_NAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_NAME.'"'.($conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_FIELD_NAME?' checked="true"':'')."></td>";
print '</tr>';
// Firstname
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'"'.($conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_FIELD_FIRSTNAME?' checked="true"':'')."></td>";
print '</tr>';
// Mail
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_FIELD_MAIL.'">';
print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_MAIL.'"'.($conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_FIELD_MAIL?' checked="true"':'')."></td>";
print '</tr>';
// Phone
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_PHONE.'"'.($conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_FIELD_PHONE?' checked="true"':'')."></td>";
print '</tr>';
// Mobile
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">';
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_MOBILE.'"'.($conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_FIELD_MOBILE?' checked="true"':'')."></td>";
print '</tr>';
// Fax
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_FAX.'"'.($conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_FIELD_FAX?' checked="true"':'')."></td>";
print '</tr>';
// Address
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldAddress").'</td><td>';
print '<input size="25" type="text" name="fieldaddress" value="'.$conf->global->LDAP_FIELD_ADDRESS.'">';
print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldAddressExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_ADDRESS.'"'.($conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_FIELD_ADDRESS?' checked="true"':'')."></td>";
print '</tr>';
// CP
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldZip").'</td><td>';
print '<input size="25" type="text" name="fieldzip" value="'.$conf->global->LDAP_FIELD_ZIP.'">';
print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldZipExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_ZIP.'"'.($conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_FIELD_ZIP?' checked="true"':'')."></td>";
print '</tr>';
// Ville
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldTown").'</td><td>';
print '<input size="25" type="text" name="fieldtown" value="'.$conf->global->LDAP_FIELD_TOWN.'">';
print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldTownExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_TOWN.'"'.($conf->global->LDAP_KEY_CONTACTS==$conf->global->LDAP_FIELD_TOWN?' checked="true"':'')."></td>";
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>';
print '</form>';

View File

@ -34,6 +34,7 @@ require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.lib.php");
$langs->load("admin");
@ -48,8 +49,10 @@ if (!$user->admin)
if ($_GET["action"] == 'setvalue' && $user->admin)
{
$error=0;
if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS',$_POST["key"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_DN',$_POST["user"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN',$_POST["group"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',$_POST["fieldfullname"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN',$_POST["fieldlogin"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA',$_POST["fieldloginsamba"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME',$_POST["fieldname"])) $error++;
@ -73,8 +76,11 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
llxHeader();
$head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives
if (! function_exists("ldap_connect"))
{
@ -85,37 +91,8 @@ if ($mesg) print '<div class="error">'.$mesg.'</div>';
else print '<br>';
// Onglets
$h = 0;
dolibarr_fiche_head($head, 'members', $langs->trans("LDAP"));
$head[$h][0] = DOL_URL_ROOT."/admin/ldap.php";
$head[$h][1] = $langs->trans("LDAPGlobalParameters");
$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");
$hselected=$h;
$h++;
}
dolibarr_fiche_head($head, $hselected, $langs->trans("LDAP"));
print $langs->trans("LDAPDescMembers").'<br>';
print '<br>';
@ -130,81 +107,102 @@ $html=new Form($db);
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeMembers").'</td>';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n";
// DN Pour les adherents
$var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPMemberDn").picto_required().'</b></td><td>';
print '<input size="38" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.'">';
print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td></tr>';
// DN pour les types
/*
$var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPMemberTypeDn").picto_required().'</b></td><td>';
print '<input size="38" type="text" name="group" value="'.$conf->global->LDAP_MEMBER_TYPE_DN.'">';
print '</td><td>'.$langs->trans("LDAPMemberTypeDnExample").'</td></tr>';
*/
print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_MEMBER_DN.'">';
print '</td><td>'.$langs->trans("LDAPMemberDnExample").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
// Filtre
/*
$var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPFilterConnection").picto_required().'</b></td><td>';
print '<input size="38" type="text" name="filterconnection" value="'.$conf->global->LDAP_FILTER_CONNECTION.'">';
print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td>';
print '</tr>';
*/
// Common name
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_FIELD_FULLNAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_FULLNAME.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_FULLNAME?' checked="true"':'')."></td>";
print '</tr>';
// Name
$var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPFieldName").picto_required().'</b></td><td>';
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_FIELD_NAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_NAME.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_NAME?' checked="true"':'')."></td>";
print '</tr>';
// Firstname
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_FIRSTNAME?' checked="true"':'')."></td>";
print '</tr>';
// Login unix
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_FIELD_LOGIN.'">';
print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_LOGIN.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_LOGIN?' checked="true"':'')."></td>";
print '</tr>';
// Login samba
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_FIELD_LOGIN_SAMBA.'">';
print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_LOGIN_SAMBA.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_LOGIN_SAMBA?' checked="true"':'')."></td>";
print '</tr>';
// Mail
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_FIELD_MAIL.'">';
print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_MAIL.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_MAIL?' checked="true"':'')."></td>";
print '</tr>';
// Phone
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td></tr>';
// Fax
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_PHONE.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_PHONE?' checked="true"':'')."></td>";
print '</tr>';
// Mobile
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">';
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_MOBILE.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_MOBILE?' checked="true"':'')."></td>";
print '</tr>';
// Fax
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_FAX.'"'.($conf->global->LDAP_KEY_MEMBERS==$conf->global->LDAP_FIELD_FAX?' checked="true"':'')."></td>";
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>';
print '</form>';

View File

@ -34,6 +34,7 @@ require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/user.class.php");
require_once(DOL_DOCUMENT_ROOT."/usergroup.class.php");
require_once(DOL_DOCUMENT_ROOT."/lib/authldap.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/ldap.lib.php");
$langs->load("admin");
@ -48,8 +49,10 @@ if (!$user->admin)
if ($_GET["action"] == 'setvalue' && $user->admin)
{
$error=0;
if (! dolibarr_set_const($db, 'LDAP_KEY_USERS',$_POST["key"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_USER_DN',$_POST["user"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_GROUP_DN',$_POST["group"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',$_POST["fieldfullname"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN',$_POST["fieldlogin"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA',$_POST["fieldloginsamba"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME',$_POST["fieldname"])) $error++;
@ -73,8 +76,11 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
llxHeader();
$head = ldap_prepare_head();
print_fiche_titre($langs->trans("LDAPSetup"),'','setup');
// Test si fonction LDAP actives
if (! function_exists("ldap_connect"))
{
@ -85,36 +91,8 @@ if ($mesg) print '<div class="error">'.$mesg.'</div>';
else print '<br>';
// Onglets
$h = 0;
dolibarr_fiche_head($head, 'users', $langs->trans("LDAP"));
$head[$h][0] = DOL_URL_ROOT."/admin/ldap.php";
$head[$h][1] = $langs->trans("LDAPGlobalParameters");
$h++;
if ($conf->global->LDAP_SYNCHRO_ACTIVE)
{
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_users.php";
$head[$h][1] = $langs->trans("LDAPUsersAndGroupsSynchro");
$hselected=$h;
$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"));
print $langs->trans("LDAPDescUsers").'<br>';
print '<br>';
@ -129,79 +107,101 @@ $html=new Form($db);
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsersAndGroup").'</td>';
print '<td colspan="3">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
print '<td>'.$langs->trans("LDAPNamingAttribute").'</td>';
print "</tr>\n";
// DN Pour les utilisateurs
$var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPUserDn").picto_required().'</b></td><td>';
print '<input size="38" type="text" name="user" value="'.$conf->global->LDAP_USER_DN.'">';
print '</td><td>'.$langs->trans("LDAPUserDnExample").'</td></tr>';
// DN pour les groupes
$var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPGroupDn").picto_required().'</b></td><td>';
print '<input size="38" type="text" name="group" value="'.$conf->global->LDAP_GROUP_DN.'">';
print '</td><td>'.$langs->trans("LDAPGroupDnExample").'</td></tr>';
print '<input size="48" type="text" name="user" value="'.$conf->global->LDAP_USER_DN.'">';
print '</td><td>'.$langs->trans("LDAPUserDnExample").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
// Filtre
/*
$var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPFilterConnection").picto_required().'</b></td><td>';
print '<input size="38" type="text" name="filterconnection" value="'.$conf->global->LDAP_FILTER_CONNECTION.'">';
print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td>';
print '</tr>';
*/
// Common name
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFullname").'</td><td>';
print '<input size="25" type="text" name="fieldfullname" value="'.$conf->global->LDAP_FIELD_FULLNAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldFullnameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_FULLNAME.'"'.($conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FULLNAME?' checked="true"':'')."></td>";
print '</tr>';
// Name
$var=!$var;
print '<tr '.$bc[$var].'><td><b>'.$langs->trans("LDAPFieldName").picto_required().'</b></td><td>';
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_FIELD_NAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_NAME.'"'.($conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_NAME?' checked="true"':'')."></td>";
print '</tr>';
// Firstname
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'">';
print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'"'.($conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FIRSTNAME?' checked="true"':'')."></td>";
print '</tr>';
// Login unix
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_FIELD_LOGIN.'">';
print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_LOGIN.'"'.($conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_LOGIN?' checked="true"':'')."></td>";
print '</tr>';
// Login samba
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_FIELD_LOGIN_SAMBA.'">';
print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_LOGIN_SAMBA.'"'.($conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_LOGIN_SAMBA?' checked="true"':'')."></td>";
print '</tr>';
// Mail
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_FIELD_MAIL.'">';
print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_MAIL.'"'.($conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_MAIL?' checked="true"':'')."></td>";
print '</tr>';
// Phone
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td></tr>';
// Fax
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_PHONE.'"'.($conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_PHONE?' checked="true"':'')."></td>";
print '</tr>';
// Mobile
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">';
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td></tr>';
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_MOBILE.'"'.($conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_MOBILE?' checked="true"':'')."></td>";
print '</tr>';
// Fax
$var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td>';
print '<td align="right"><input type="radio" name="key" value="'.$conf->global->LDAP_FIELD_FAX.'"'.($conf->global->LDAP_KEY_USERS==$conf->global->LDAP_FIELD_FAX?' checked="true"':'')."></td>";
print '</tr>';
$var=!$var;
print '<tr '.$bc[$var].'><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '<tr '.$bc[$var].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>';
print '</form>';
@ -219,7 +219,6 @@ if (function_exists("ldap_connect"))
{
print '<br>';
print '<a class="tabAction" href="'.$_SERVER["PHP_SELF"].'?action=testuser">'.$langs->trans("LDAPTestSynchroUser").'</a>';
print '<a class="tabAction" href="'.$_SERVER["PHP_SELF"].'?action=testgroup">'.$langs->trans("LDAPTestSynchroGroup").'</a>';
print '<br><br>';
}
@ -248,32 +247,6 @@ if (function_exists("ldap_connect"))
}
}
if ($_GET["action"] == 'testgroup')
{
// Creation contact
$fgroup=new UserGroup($db);
$fgroup->initAsSpecimen();
// Test synchro
//$result1=$fgroup->delete_ldap($user);
$result2=$fgroup->update_ldap($user);
$result3=$fgroup->delete_ldap($user);
if ($result2 > 0)
{
print img_picto('','info').' ';
print '<font class="ok">'.$langs->trans("LDAPSynchroOK").'</font><br>';
}
else
{
print img_picto('','error').' ';
print '<font class="warning">'.$langs->trans("LDAPSynchroKO");
print ': '.$fgroup->error;
print '</font><br>';
}
}
}
$db->close();

View File

@ -119,6 +119,13 @@ class Conf
if (! $this->global->MAIN_MENU_BARRELEFT) $this->global->MAIN_MENU_BARRELEFT="default.php";
if (! $this->global->MAIN_MENUFRONT_BARRELEFT) $this->global->MAIN_MENUFRONT_BARRELEFT="default.php";
// Variable globales LDAP
if (! $this->global->LDAP_KEY_USERS) $this->global->LDAP_KEY_USERS=$this->global->LDAP_FIELD_FULLNAME;
if (! $this->global->LDAP_KEY_GROUPS) $this->global->LDAP_KEY_GROUPS=$this->global->LDAP_FIELD_FULLNAME;
if (! $this->global->LDAP_KEY_CONTACTS) $this->global->LDAP_KEY_CONTACTS=$this->global->LDAP_FIELD_FULLNAME;
if (! $this->global->LDAP_KEY_MEMBERS) $this->global->LDAP_KEY_MEMBERS=$this->global->LDAP_FIELD_FULLNAME;
/*
* Charge l'objet de traduction et positionne langage courant global
*/

View File

@ -233,9 +233,9 @@ class Contact
if ($bind)
{
$info["cn"] = trim($this->firstname." ".$this->name);
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
$info=$this->_load_ldap_info($info);
$dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN;
$result=$ldap->delete($dn);
return $result;
@ -250,8 +250,81 @@ class Contact
}
function _load_ldap_info($info)
{
global $conf,$langs;
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"user");
}
else
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"inetOrgPerson");
}
// Champs
if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname;
if ($this->name && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->name;
if ($this->firstname && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->firstname;
if ($this->poste) $info["title"] = $this->poste;
if ($this->socid > 0)
{
$soc = new Societe($this->db);
$soc->fetch($this->socid);
$info["o"] = $soc->nom;
if ($soc->client == 1) $info["businessCategory"] = "Customers";
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
}
if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp;
if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville;
if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro;
if ($this->phone_perso) $info["homePhone"] = $this->phone_perso;
if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile;
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
if ($this->note) $info["description"] = $this->note;
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
{
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
$info['uidnumber'] = $this->id;
$info['phpgwTz'] = 0;
$info['phpgwMailType'] = 'INTERNET';
$info['phpgwMailHomeType'] = 'INTERNET';
$info["phpgwContactTypeId"] = 'n';
$info["phpgwContactCatId"] = 0;
$info["phpgwContactAccess"] = "public";
if (strlen($this->egroupware_id) == 0)
{
$this->egroupware_id = 1;
}
$info["phpgwContactOwner"] = $this->egroupware_id;
if ($this->email) $info["rfc822Mailbox"] = $this->email;
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
}
return $info;
}
/**
* \brief Creation d'un contact dans l'arbre LDAP
* \brief Creation dans l'arbre LDAP
* \param user Utilisateur qui effectue la creation
* \return int <0 si ko, >0 si ok
*/
@ -294,90 +367,19 @@ class Contact
}
if ($bind)
{
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"user");
}
else
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"inetOrgPerson");
}
$info=$this->_load_ldap_info($info);
// Champs obligatoires
$info["cn"] = trim($this->firstname." ".$this->name);
if ($this->name) $info[$conf->global->LDAP_FIELD_NAME] = $this->name;
else
{
$langs->load("other");
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Name"));
return -1;
}
// Champs optionnels
if ($this->firstname && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->firstname;
if ($this->poste) $info["title"] = $this->poste;
if ($this->socid > 0)
{
$soc = new Societe($this->db);
$soc->fetch($this->socid);
$info["o"] = $soc->nom;
if ($soc->client == 1) $info["businessCategory"] = "Customers";
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
}
if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp;
if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville;
if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro;
if ($this->phone_perso) $info["homePhone"] = $this->phone_perso;
if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile;
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
if ($this->note) $info["description"] = $this->note;
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
{
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
$info['uidnumber'] = $this->id;
$info['phpgwTz'] = 0;
$info['phpgwMailType'] = 'INTERNET';
$info['phpgwMailHomeType'] = 'INTERNET';
$info["phpgwContactTypeId"] = 'n';
$info["phpgwContactCatId"] = 0;
$info["phpgwContactAccess"] = "public";
if (strlen($user->egroupware_id) == 0)
{
$user->egroupware_id = 1;
}
$info["phpgwContactOwner"] = $user->egroupware_id;
if ($this->email) $info["rfc822Mailbox"] = $this->email;
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
}
$info["uid"] = "Dolibarr ".$this->id. ": ".trim($this->firstname." ".$this->name);
$newdn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
$olddn = $newdn;
if ($this->old_firstname || $this->old_name) $olddn="cn=".trim($this->old_firstname." ".$this->old_name).",".$conf->global->LDAP_CONTACT_DN;
// Definitition du DN
$dn = $conf->global->LDAP_KEY_CONTACTS."=".$info[$conf->global->LDAP_KEY_CONTACTS].",".$conf->global->LDAP_CONTACT_DN;
$olddn = $dn;
if (($this->old_firstname || $this->old_name) && $conf->global->LDAP_KEY_CONTACTS=="cn")
$olddn=$conf->global->LDAP_KEY_CONTACTS."=".trim($this->old_firstname." ".$this->old_name).",".$conf->global->LDAP_CONTACT_DN;
// On supprime et on insère
dolibarr_syslog("Contact.class::update_ldap olddn=".$olddn." newdn=".$newdn);
dolibarr_syslog("User.class::update_ldap dn=".$dn." olddn=".$olddn);
$result = $ldap->delete($olddn);
$result = $ldap->add($newdn, $info);
$result = $ldap->add($dn, $info);
if ($result <= 0)
{
$this->error = ldap_errno($ldap->connection)." ".ldap_error($ldap->connection)." ".$ldap->error;

View File

@ -115,9 +115,21 @@ print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $form->civilite_name($contact->civilite_id);
print '</td></tr>';
// Nom
print '<tr><td width="20%">'.$langs->trans("Lastname").'</td><td>'.$contact->name.'</td>';
// Prenom
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>';
// LDAP DN
$langs->load("admin");
print '<tr><td>'.$langs->trans("LDAPContactDn").'*</td><td class="valeur">'.$conf->global->LDAP_CONTACT_DN."</td></tr>\n";
// LDAP Server
print '<tr><td>'.$langs->trans("LDAPPrimaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
print '<tr><td>'.$langs->trans("LDAPSecondaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
print '<tr><td>'.$langs->trans("LDAPServerPort").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
print '</table>';
print '</div>';
@ -146,7 +158,7 @@ if ($result)
dolibarr_syslog("ldap.php: authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
}
else
if (! $bind) // Si pas de login ou si connexion avec login en echec, on tente en anonyme
{
dolibarr_syslog("ldap.php: bind",LOG_DEBUG);
$bind=$ldap->bind();
@ -155,9 +167,14 @@ if ($result)
if ($bind)
{
$info["cn"] = trim($contact->firstname." ".$contact->name);
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
$result=$ldap->search($dn,'(objectClass=*)');
$dn = $conf->global->LDAP_CONTACT_DN;
// $dn = "cn=".$info["cn"].",".$dn;
// $dn = "uid=".$info["uid"].",".$dn
$search = "(cn=".$info["cn"].")";
//$search = "(uid=".$info["uid"].")";
$result=$ldap->search($dn,$search);
// Affichage arbre
if (sizeof($result))
@ -169,15 +186,18 @@ if ($result)
{
print '<tr><td colspan="2">'.$langs->trans("LDAPRecordNotFound").'</td></tr>';
}
$ldap->unbind();
}
else
{
dolibarr_print_error('',$ldap);
dolibarr_print_error('',$ldap->error);
}
$ldap->close();
}
else
{
dolibarr_print_error('',$ldap);
dolibarr_print_error('',$ldap->error);
}
print '</table>';

View File

@ -55,7 +55,7 @@ class Don
var $statut;
var $projet;
var $errorstr;
var $error;
/**
* \brief Constructeur
@ -186,10 +186,10 @@ class Don
*/
function print_error_list()
{
$num = sizeof($this->errorstr);
$num = sizeof($this->error);
for ($i = 0 ; $i < $num ; $i++)
{
print "<li>" . $this->errorstr[$i];
print "<li>" . $this->error[$i];
}
}
@ -267,7 +267,7 @@ class Don
if ($err)
{
$this->errorstr = $error_string;
$this->error = $error_string;
return 0;
}
else

View File

@ -41,7 +41,7 @@
class Form
{
var $db;
var $errorstr;
var $error;
var $cache_types_paiements_code=array();
var $cache_types_paiements_libelle=array();
@ -2372,7 +2372,7 @@ class Form
*/
function error()
{
return $this->errorstr;
return $this->error;
}

View File

@ -64,7 +64,7 @@ class FormMail
var $substit=array();
var $param=array();
var $errorstr;
var $error;
/**

View File

@ -492,14 +492,19 @@ AdherentMailRequired=EMail required to create a new member
##### LDAP setup #####
LDAPSetup=LDAP Setup
LDAPGlobalParameters=Global parameters
LDAPUsersAndGroupsSynchro=Users/groups synchro
LDAPContactsSynchro=Contacts synchro
LDAPUsersSynchro=Users
LDAPGroupsSynchro=Groups
LDAPContactsSynchro=Contacts
LDAPMembersSynchro=Members
LDAPSynchronization=LDAP synchronisation
LDAPFunctionsNotAvailableOnPHP=LDAP functions are not availbale on your PHP
LDAPSynchronizeUsersAndGroup=Synchronize Dolibarr users and groups with LDAP
LDAPToDolibarr=LDAP -> Dolibarr
DolibarrToLDAP=Dolibarr -> LDAP
LDAPNamingAttribute=Key
LDAPSynchronizeUsers=Synchronize Dolibarr users with LDAP
LDAPSynchronizeGroups=Synchronize Dolibarr groups with LDAP
LDAPSynchronizeContacts=Synchronize Dolibarr contacts with LDAP
LDAPSynchronizeMembers=Synchronize members of Dolibarr fundation module with LDAP
LDAPTypeExample=OpenLdap, Egroupware or Active Directory
LDAPPrimaryServer=LDAP primary server
LDAPSecondaryServer=LDAP secondary server
@ -524,8 +529,14 @@ LDAPDnSynchroActiveExample=LDAP to Dolibarr or Dolibarr to LDAP synchronization
LDAPDnContactActive=Contacts' synchronization
LDAPDnContactActiveYes=Activated synchronization
LDAPDnContactActiveExample=Activated/Unactivated synchronization
LDAPDnMemberActive=Members' synchronization
LDAPDnMemberActiveExample=Activated/Unactivated synchronization
LDAPContactDn=Dolibarr contacts' DN
LDAPContactDnExample=Complete DN (ex: ou=contacts,dc=society,dc=com)
LDAPMemberDn=Dolibarr members' DN
LDAPMemberDnExample=Complete DN (ex: ou=members,dc=society,dc=com)
LDAPMemberTypeDn=Dolibarr member's type DN
LDAPMemberTypeDnExample=Complete DN (ex: ou=type_members,dc=society,dc=com)
LDAPTestConnect=Test LDAP connection
LDAPTestSynchroContact=Test contact's synchronization
LDAPTestSynchroUser=Test user's synchronization
@ -544,35 +555,39 @@ LDAPConnectToDNFailed=Connection au DN (%s)
LDAPSetupForVersion3=LDAP server configured for version 3
LDAPSetupForVersion2=LDAP server configured for version 2
LDAPFieldLoginUnix=Login (unix)
LDAPFieldLoginExample=Suggested value : uid
LDAPFieldLoginExample=Example : uid
LDAPFilterConnection=Search filter
LDAPFilterConnectionExample=Suggested value : &(objectClass=user)(objectCategory=person)
LDAPFilterConnectionExample=Example : &(objectClass=user)(objectCategory=person)
LDAPFieldLoginSamba=Login (samba, activedirectory)
LDAPFieldLoginSambaExample=Suggested value : samaccountname (Samba and ActiveDirectory)
LDAPFieldLoginSambaExample=Example : samaccountname
LDAPFieldFullname=Firstname Name
LDAPFieldFullnameExample=Example : cn
LDAPFieldName=Name
LDAPFieldNameExample=Suggested value : sn
LDAPFieldNameExample=Example : sn
LDAPFieldFirstName=Firstname
LDAPFieldFirstNameExample=Suggested value : givenname
LDAPFieldFirstNameExample=Example : givenname
LDAPFieldMail=Email address
LDAPFieldMailExample=Suggested value : mail
LDAPFieldMailExample=Example : mail
LDAPFieldPhone=Phone number
LDAPFieldPhoneExample=Suggested value : telephonenumber
LDAPFieldPhoneExample=Example : telephonenumber
LDAPFieldFax=Fax number
LDAPFieldFaxExample=Suggested value : facsimiletelephonenumber
LDAPFieldFaxExample=Example : facsimiletelephonenumber
LDAPFieldMobile=Cellular phone
LDAPFieldMobileExample=Suggested value : mobile
LDAPFieldMobileExample=Example : mobile
LDAPFieldAddress=Street
LDAPFieldAddressExample=Valeur recommandée : street
LDAPFieldAddressExample=Example : street
LDAPFieldZip=Zip
LDAPFieldZipExample=Valeur recommandée : postalcode
LDAPFieldZipExample=Example : postalcode
LDAPFieldTown=Town
LDAPFieldTownExample=Valeur recommandée : l
LDAPFieldTownExample=Example : l
LDAPParametersAreStillHardCoded=LDAP parametres are still hardcoded (in contact class)
LDAPSetupNotComplete=LDAP setup not complete (go on others tabs)
LDAPNoUserOrPasswordProvidedAccessIsReadOnly=No administrator or password provided. LDAP access will be anonymous and in read only mode.
LDAPDescContact=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr contacts.
LDAPDescUsers=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr users.
LDAPDescValues=Suggested values are designed for <b>OpenLDAP</b> with following loaded schemas: <b>core.schema, cosine.schema, inetorgperson.schema</b>). If you use thoose values and OpenLDAP, modify your LDAP config file <b>slapd.conf</b> to have all thoose schemas loaded.
LDAPDescGroups=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr groups.
LDAPDescMembers=This page allows you to define LDAP attributes name in LDAP tree for each data found on Dolibarr members module.
LDAPDescValues=Example values are designed for <b>OpenLDAP</b> with following loaded schemas: <b>core.schema, cosine.schema, inetorgperson.schema</b>). If you use thoose values and OpenLDAP, modify your LDAP config file <b>slapd.conf</b> to have all thoose schemas loaded.
##### Products #####
ProductSetup=Products module setup
NumberOfProductShowInSelect=Max number of products in combos select lists (0=no limit)

View File

@ -7,6 +7,7 @@ LdapUacf_ACCOUNTDISABLE=Account is disabled on this domain
LDAPInformationsForThisContact=Informations in LDAP database for this contact
LDAPInformationsForThisUser=Informations in LDAP database for this user
LDAPInformationsForThisGroup=Informations in LDAP database for this group
LDAPInformationsForThisMember=Informations in LDAP database for this member
LDAPAttribute=LDAP attribute
LDAPAttributes=LDAP attributes
LDAPCard=LDAP card

View File

@ -63,6 +63,7 @@ AddActionDone=Add action done
Close=Close
Close2=Close
Confirm=Confirm
ConfirmSendCardByMail=Do you really want to send this card by mail ?
Delete=Delete
Remove=Remove
Resiliate=Resiliate

View File

@ -492,14 +492,19 @@ AdherentMailRequired=EMail obligatoire pour cr
##### LDAP setup #####
LDAPSetup=Configuration du module LDAP
LDAPGlobalParameters=Paramètres globals
LDAPUsersAndGroupsSynchro=Synchro utilisateurs/groupes
LDAPContactsSynchro=Synchro contacts
LDAPUsersSynchro=Utilisateurs
LDAPGroupsSynchro=Groupes
LDAPContactsSynchro=Contacts
LDAPMembersSynchro=Adhérents
LDAPSynchronization=Synchronisation LDAP
LDAPFunctionsNotAvailableOnPHP=Les fonctions LDAP ne sont pas disponibles sur votre PHP
LDAPSynchronizeUsersAndGroup=Synchronisation des utilisateurs et groupes Dolibarr avec LDAP
LDAPToDolibarr=LDAP -> Dolibarr
DolibarrToLDAP=Dolibarr -> LDAP
LDAPNamingAttribute=Clé
LDAPSynchronizeUsers=Synchronisation des utilisateurs Dolibarr avec LDAP
LDAPSynchronizeGroups=Synchronisation des groupes utilisateurs Dolibarr avec LDAP
LDAPSynchronizeContacts=Synchronisation des contacts Dolibarr avec LDAP
LDAPSynchronizeMembers=Synchronisation des membres du module adhérents de Dolibarr avec LDAP
LDAPTypeExample=OpenLdap, Egroupware ou Active Directory
LDAPPrimaryServer=Serveur primaire
LDAPSecondaryServer=Serveur secondaire
@ -524,8 +529,14 @@ LDAPDnSynchroActiveExample=Synchronisation de LDAP vers Dolibarr ou Dolibarr ver
LDAPDnContactActive=Synchronisation des contacts
LDAPDnContactActiveYes=Synchronisation activée
LDAPDnContactActiveExample=Synchronisation activée/désactivée
LDAPDnMemberActive=Synchronisation des adhérents
LDAPDnMemberActiveExample=Synchronisation activée/désactivée
LDAPContactDn=DN des contacts Dolibarr
LDAPContactDnExample=DN complet (ex: ou=contacts,dc=my-domain,dc=com)
LDAPMemberDn=DN des adhérents
LDAPMemberDnExample=DN complet (ex: ou=members,dc=society,dc=com)
LDAPMemberTypeDn=DN des types d'adhérents
LDAPMemberTypeDnExample=DN complet (ex: ou=type_members,dc=society,dc=com)
LDAPTestConnect=Tester la connexion LDAP
LDAPTestSynchroContact=Tester synchronisation contacts
LDAPTestSynchroUser=Tester synchronisation utilisateur
@ -544,35 +555,39 @@ LDAPConnectToDNFailed=Connection au DN (%s)
LDAPSetupForVersion3=Serveur LDAP configuré en version 3
LDAPSetupForVersion2=Serveur LDAP configuré en version 2
LDAPFieldLoginUnix=Login (unix)
LDAPFieldLoginExample=Valeur recommandée : uid
LDAPFieldLoginExample=Exemple : uid
LDAPFilterConnection=Filtre de recherche
LDAPFilterConnectionExample=Valeur recommandée : &(objectClass=user)(objectCategory=person)
LDAPFilterConnectionExample=Exemple : &(objectClass=user)(objectCategory=person)
LDAPFieldLoginSamba=Login (samba, activedirectory)
LDAPFieldLoginSambaExample=Valeur recommandée : samaccountname (Samba et ActiveDirectory)
LDAPFieldLoginSambaExample=Exemple : samaccountname
LDAPFieldFullname=Prénom Nom
LDAPFieldFullnameExample=Exemple : cn
LDAPFieldName=Nom
LDAPFieldNameExample=Valeur recommandée : sn
LDAPFieldNameExample=Exemple : sn
LDAPFieldFirstName=Prénom
LDAPFieldFirstNameExample=Valeur recommandée : givenname
LDAPFieldFirstNameExample=Exemple : givenname
LDAPFieldMail=Email
LDAPFieldMailExample=Valeur recommandée : mail
LDAPFieldMailExample=Exemple : mail
LDAPFieldPhone=Téléphone
LDAPFieldPhoneExample=Valeur recommandée : telephonenumber
LDAPFieldPhoneExample=Exemple : telephonenumber
LDAPFieldFax=Fax
LDAPFieldFaxExample=Valeur recommandée : facsimiletelephonenumber
LDAPFieldFaxExample=Exemple : facsimiletelephonenumber
LDAPFieldMobile=Téléphone portable
LDAPFieldMobileExample=Valeur recommandée : mobile
LDAPFieldMobileExample=Exemple : mobile
LDAPFieldAddress=Adresse
LDAPFieldAddressExample=Valeur recommandée : street
LDAPFieldAddressExample=Exemple : street
LDAPFieldZip=Code postal
LDAPFieldZipExample=Valeur recommandée : postalcode
LDAPFieldZipExample=Exemple : postalcode
LDAPFieldTown=Ville
LDAPFieldTownExample=Valeur recommandée : l
LDAPFieldTownExample=Exemple : l
LDAPParametersAreStillHardCoded=Les parametres LDAP sont codés en dur (dans classe contact)
LDAPSetupNotComplete=Configuration LDAP incomplète (à compléter sur les autres onglets)
LDAPNoUserOrPasswordProvidedAccessIsReadOnly=Administrateur ou mot de passe non renseigné. Les accès LDAP seront donc anonymes et en lecture seule.
LDAPDescContact=Cette page permet de définir le nom des attributs de l'arbre LDAP pour chaque informations des contacts Dolibarr.
LDAPDescUsers=Cette page permet de définir le nom des attributs de l'arbre LDAP pour chaque informations des utilisateurs Dolibarr.
LDAPDescValues=Les valeurs recommandées sont adaptées à <b>OpenLDAP</b> avec les schemas suivant chargés: <b>core.schema, cosine.schema, inetorgperson.schema</b>). Si vous utiliser les valeurs suggérés et OpenLDAP, modifier votre fichier de configuration LDAP <b>slapd.conf</b> pour avoir tous ces schémas actifs.
LDAPDescGroups=Cette page permet de définir le nom des attributs de l'arbre LDAP pour chaque informations des groupes utilisateurs Dolibarr.
LDAPDescMembers=Cette page permet de définir le nom des attributs de l'arbre LDAP pour chaque informations des membres du module adhérents Dolibarr.
LDAPDescValues=Les valeurs exemples sont adaptées à <b>OpenLDAP</b> avec les schemas suivant chargés: <b>core.schema, cosine.schema, inetorgperson.schema</b>). Si vous utiliser les valeurs suggérés et OpenLDAP, modifier votre fichier de configuration LDAP <b>slapd.conf</b> pour avoir tous ces schémas actifs.
##### Products #####
ProductSetup=Configuration du module Produits
NumberOfProductShowInSelect=Nombre de produits max dans les listes déroulantes (0=aucune limite)

View File

@ -7,6 +7,7 @@ LdapUacf_ACCOUNTDISABLE=Le compte est d
LDAPInformationsForThisContact=Informations en base LDAP pour ce contact
LDAPInformationsForThisUser=Informations en base LDAP pour cet utilisateur
LDAPInformationsForThisGroup=Informations en base LDAP pour ce groupe
LDAPInformationsForThisMember=Informations en base LDAP pour ce membre
LDAPAttribute=Attribut LDAP
LDAPAttributes=Attributs LDAP
LDAPCard=Fiche LDAP

View File

@ -63,6 +63,7 @@ AddActionDone=Ajouter action faite
Close=Clôturer
Close2=Fermer
Confirm=Confirmer
ConfirmSendCardByMail=Voulez vous envoyer cette fiche par mail ?
Delete=Supprimer
Remove=Enlever
Resiliate=Résilier

View File

@ -174,10 +174,10 @@ class AuthLdap {
* 2.1.2 : Simply closes the connection set up earlier.
* Returns true if OK, false if there was an error.
*/
function close() {
if ( !@ldap_close($this->connection)) {
$this->ldapErrorCode = ldap_errno( $this->connection);
$this->ldapErrorText = ldap_error( $this->connection);
function close()
{
if ($this->connection && ! @ldap_close($this->connection))
{
return false;
} else {
return true;
@ -192,6 +192,7 @@ class AuthLdap {
if ( !$this->result=@ldap_bind( $this->connection)) {
$this->ldapErrorCode = ldap_errno( $this->connection);
$this->ldapErrorText = ldap_error( $this->connection);
$this->error=$this->ldapErrorCode." ".$this->ldapErrorText;
return false;
} else {
return true;
@ -224,6 +225,7 @@ class AuthLdap {
if ( !$this->result = @ldap_bind( $this->connection,$bindDn,$pass)) {
$this->ldapErrorCode = ldap_errno( $this->connection);
$this->ldapErrorText = ldap_error( $this->connection);
$this->error=$this->ldapErrorCode." ".$this->ldapErrorText;
return false;
} else {
return true;

81
htdocs/lib/ldap.lib.php Normal file
View File

@ -0,0 +1,81 @@
<?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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.
* or see http://www.gnu.org/
*
* $Id$
* $Source$
*/
/**
\file htdocs/lib/ldap.lib.php
\brief Ensemble de fonctions de base pour le module LDAP
\ingroup ldap
\version $Revision$
Ensemble de fonctions de base de dolibarr sous forme d'include
*/
function ldap_prepare_head()
{
global $langs, $conf, $user;
$langs->load("ldap");
// Onglets
$head=array();
$h = 0;
$head[$h][0] = DOL_URL_ROOT."/admin/ldap.php";
$head[$h][1] = $langs->trans("LDAPGlobalParameters");
$head[$h][2] = 'ldap';
$h++;
if ($conf->global->LDAP_SYNCHRO_ACTIVE)
{
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_users.php";
$head[$h][1] = $langs->trans("LDAPUsersSynchro");
$head[$h][2] = 'users';
$h++;
}
if ($conf->global->LDAP_SYNCHRO_ACTIVE)
{
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_groups.php";
$head[$h][1] = $langs->trans("LDAPGroupsSynchro");
$head[$h][2] = 'groups';
$h++;
}
if ($conf->global->LDAP_CONTACT_ACTIVE)
{
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_contacts.php";
$head[$h][1] = $langs->trans("LDAPContactsSynchro");
$head[$h][2] = 'contacts';
$h++;
}
if ($conf->global->LDAP_MEMBERS_ACTIVE)
{
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_members.php";
$head[$h][1] = $langs->trans("LDAPMembersSynchro");
$head[$h][2] = 'members';
$h++;
}
return $head;
}
?>

56
htdocs/lib/member.lib.php Normal file
View File

@ -0,0 +1,56 @@
<?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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.
* or see http://www.gnu.org/
*
* $Id$
* $Source$
*/
/**
\file htdocs/lib/memeber.lib.php
\brief Ensemble de fonctions de base pour les adhérents
\version $Revision$
Ensemble de fonctions de base de dolibarr sous forme d'include
*/
function member_prepare_head($member)
{
global $langs, $conf;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$member->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'general';
$h++;
if ($conf->ldap->enabled && $conf->global->LDAP_MEMBERS_ACTIVE)
{
$langs->load("ldap");
$head[$h][0] = DOL_URL_ROOT.'/adherents/ldap.php?id='.$member->id;
$head[$h][1] = $langs->trans("LDAPCard");
$head[$h][2] = 'ldap';
$h++;
}
return $head;
}
?>

View File

@ -1195,6 +1195,18 @@ class User
}
/**
* \brief Creation dans l'arbre LDAP
* \param user Utilisateur qui effectue la creation
* \return int <0 si ko, >0 si ok
*/
function create_ldap($user)
{
dolibarr_syslog("User.class::create_ldap this->id=".$this->id,LOG_DEBUG);
return $this->update_ldap($user);
}
/**
* \brief Mise à jour dans l'arbre LDAP
* \param user Utilisateur qui effectue la mise à jour
@ -1227,90 +1239,19 @@ class User
}
if ($bind)
{
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"user");
}
else
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"inetOrgPerson");
}
$info=$this->_load_ldap_info($info);
// Champs obligatoires
$info["cn"] = trim($this->prenom." ".$this->nom);
if ($this->nom) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;
else
{
$langs->load("other");
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Name"));
return -1;
}
// Champs optionnels
if ($this->prenom && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->prenom;
if ($this->poste) $info["title"] = $this->poste;
if ($this->societe_id > 0)
{
$soc = new Societe($this->db);
$soc->fetch($this->societe_id);
$info["o"] = $soc->nom;
if ($soc->client == 1) $info["businessCategory"] = "Customers";
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
}
if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp;
if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville;
if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro;
if ($this->phone_perso) $info["homePhone"] = $this->phone_perso;
if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile;
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
if ($this->note) $info["description"] = $this->note;
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
{
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
$info['uidnumber'] = $this->id;
$info['phpgwTz'] = 0;
$info['phpgwMailType'] = 'INTERNET';
$info['phpgwMailHomeType'] = 'INTERNET';
$info["phpgwContactTypeId"] = 'n';
$info["phpgwContactCatId"] = 0;
$info["phpgwContactAccess"] = "public";
if (strlen($user->egroupware_id) == 0)
{
$user->egroupware_id = 1;
}
$info["phpgwContactOwner"] = $user->egroupware_id;
if ($this->email) $info["rfc822Mailbox"] = $this->email;
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
}
$info["uid"] = "Dolibarr ".$this->ldap_sid;
$newdn = "cn=".$info["cn"].",".$conf->global->LDAP_USER_DN;
$olddn = $newdn;
if ($this->old_firstname || $this->old_name) $olddn="cn=".trim($this->old_firstname." ".$this->old_name).",".$conf->global->LDAP_CONTACT_DN;
// Definitition du DN
$dn = $conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".$conf->global->LDAP_USER_DN;
$olddn = $dn;
if (($this->old_firstname || $this->old_name) && $conf->global->LDAP_KEY_USERS=="cn")
$olddn=$conf->global->LDAP_KEY_USERS."=".trim($this->old_firstname." ".$this->old_name).",".$conf->global->LDAP_USER_DN;
// On supprime et on insère
dolibarr_syslog("User.class::update_ldap olddn=".$olddn." newdn=".$newdn);
dolibarr_syslog("User.class::update_ldap dn=".$dn." olddn=".$olddn);
$result = $ldap->delete($olddn);
$result = $ldap->add($newdn, $info);
$result = $ldap->add($dn, $info);
if ($result <= 0)
{
$this->error = ldap_errno($ldap->connection)." ".ldap_error($ldap->connection)." ".$ldap->error;
@ -1374,9 +1315,9 @@ class User
if ($bind)
{
$info["cn"] = trim($this->prenom." ".$this->nom);
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_USER_DN;
$info=$this->_load_ldap_info($info);
$dn = $conf->global->LDAP_KEY_USERS."=".$info[$conf->global->LDAP_KEY_USERS].",".$conf->global->LDAP_USER_DN;
$result=$ldap->delete($dn);
return $result;
@ -1390,6 +1331,80 @@ class User
}
}
function _load_ldap_info($info)
{
global $conf,$langs;
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"user");
}
else
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"inetOrgPerson");
}
// Champs
if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname;
if ($this->nom && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;
if ($this->prenom && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->prenom;
if ($this->login && $conf->global->LDAP_FIELD_LOGIN) $info[$conf->global->LDAP_FIELD_LOGIN] = $this->login;
if ($this->poste) $info["title"] = $this->poste;
if ($this->societe_id > 0)
{
$soc = new Societe($this->db);
$soc->fetch($this->societe_id);
$info["o"] = $soc->nom;
if ($soc->client == 1) $info["businessCategory"] = "Customers";
if ($soc->client == 2) $info["businessCategory"] = "Prospects";
if ($soc->fournisseur == 1) $info["businessCategory"] = "Suppliers";
}
if ($this->address && $conf->global->LDAP_FIELD_ADDRESS) $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address;
if ($this->cp && $conf->global->LDAP_FIELD_ZIP) $info[$conf->global->LDAP_FIELD_ZIP] = $this->cp;
if ($this->ville && $conf->global->LDAP_FIELD_TOWN) $info[$conf->global->LDAP_FIELD_TOWN] = $this->ville;
if ($this->phone_pro && $conf->global->LDAP_FIELD_PHONE) $info[$conf->global->LDAP_FIELD_PHONE] = $this->phone_pro;
if ($this->phone_perso) $info["homePhone"] = $this->phone_perso;
if ($this->phone_mobile && $conf->global->LDAP_FIELD_MOBILE) $info[$conf->global->LDAP_FIELD_MOBILE] = $this->phone_mobile;
if ($this->fax && $conf->global->LDAP_FIELD_FAX) $info[$conf->global->LDAP_FIELD_FAX] = $this->fax;
if ($this->note) $info["description"] = $this->note;
if ($this->email && $conf->global->LDAP_FIELD_MAIL) $info[$conf->global->LDAP_FIELD_MAIL] = $this->email;
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
{
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
$info['uidnumber'] = $this->id;
$info['phpgwTz'] = 0;
$info['phpgwMailType'] = 'INTERNET';
$info['phpgwMailHomeType'] = 'INTERNET';
$info["phpgwContactTypeId"] = 'n';
$info["phpgwContactCatId"] = 0;
$info["phpgwContactAccess"] = "public";
if (strlen($this->egroupware_id) == 0)
{
$this->egroupware_id = 1;
}
$info["phpgwContactOwner"] = $this->egroupware_id;
if ($this->email) $info["rfc822Mailbox"] = $this->email;
if ($this->phone_mobile) $info["phpgwCellTelephoneNumber"] = $this->phone_mobile;
}
return $info;
}
/**
* \brief Initialise le user avec valeurs fictives aléatoire

View File

@ -84,6 +84,16 @@ print "</tr>\n";
print '<tr><td width="25%" valign="top">'.$langs->trans("Note").'</td>';
print '<td class="valeur">'.nl2br($fgroup->note).'&nbsp;</td>';
print "</tr>\n";
// LDAP DN
$langs->load("admin");
print '<tr><td>'.$langs->trans("LDAPGroupDn").'*</td><td class="valeur">'.$conf->global->LDAP_GROUP_DN."</td></tr>\n";
// LDAP Server
print '<tr><td>'.$langs->trans("LDAPPrimaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
print '<tr><td>'.$langs->trans("LDAPSecondaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
print '<tr><td>'.$langs->trans("LDAPServerPort").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
print "</table>\n";
print '</div>';
@ -112,7 +122,7 @@ if ($result)
dolibarr_syslog("ldap.php: authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
}
else
if (! $bind) // Si pas de login ou si connexion avec login en echec, on tente en anonyme
{
dolibarr_syslog("ldap.php: bind",LOG_DEBUG);
$bind=$ldap->bind();
@ -120,11 +130,15 @@ if ($result)
if ($bind)
{
// $info["cn"] = $ldap->getUserIdentifier()."=".$fuser->uname;
$info["cn"] = trim($fgroup->nom);
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_GROUP_DN;
$result=$ldap->search($dn,'(objectClass=*)');
$dn = $conf->global->LDAP_GROUP_DN;
// $dn = "cn=".$info["cn"].",".$dn;
// $dn = "uid=".$info["uid"].",".$dn
$search = "(cn=".$info["cn"].")";
//$search = "(uid=".$info["uid"].")";
$result=$ldap->search($dn,$search);
// Affichage arbre
if (sizeof($result))
@ -136,15 +150,18 @@ if ($result)
{
print '<tr><td colspan="2">'.$langs->trans("LDAPRecordNotFound").'</td></tr>';
}
$ldap->unbind();
}
else
{
dolibarr_print_error('',$ldap);
dolibarr_print_error('',$ldap->error);
}
$ldap->close();
}
else
{
dolibarr_print_error('',$ldap);
dolibarr_print_error('',$ldap->error);
}
print '</table>';

View File

@ -100,6 +100,15 @@ else
}
print '</tr>';
// LDAP DN
$langs->load("admin");
print '<tr><td>'.$langs->trans("LDAPUserDn").'*</td><td class="valeur">'.$conf->global->LDAP_USER_DN."</td></tr>\n";
// LDAP Server
print '<tr><td>'.$langs->trans("LDAPPrimaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
print '<tr><td>'.$langs->trans("LDAPSecondaryServer").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
print '<tr><td>'.$langs->trans("LDAPServerPort").'*</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
print '</table>';
print '</div>';
@ -128,7 +137,7 @@ if ($result)
dolibarr_syslog("ldap.php: authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
}
else
if (! $bind) // Si pas de login ou si connexion avec login en echec, on tente en anonyme
{
dolibarr_syslog("ldap.php: bind",LOG_DEBUG);
$bind=$ldap->bind();
@ -136,11 +145,15 @@ if ($result)
if ($bind)
{
// $info["cn"] = $ldap->getUserIdentifier()."=".$fuser->uname;
$info["cn"] = trim($fuser->prenom." ".$fuser->nom);
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_USER_DN;
$result=$ldap->search($dn,'(objectClass=*)');
$dn = $conf->global->LDAP_USER_DN;
// $dn = "cn=".$info["cn"].",".$dn;
// $dn = "uid=".$info["uid"].",".$dn
$search = "(cn=".$info["cn"].")";
//$search = "(uid=".$info["uid"].")";
$result=$ldap->search($dn,$search);
// Affichage arbre
if (sizeof($result))
@ -152,15 +165,18 @@ if ($result)
{
print '<tr><td colspan="2">'.$langs->trans("LDAPRecordNotFound").'</td></tr>';
}
$ldap->unbind();
}
else
{
dolibarr_print_error('',$ldap);
dolibarr_print_error('',$ldap->error);
}
$ldap->close();
}
else
{
dolibarr_print_error('',$ldap);
dolibarr_print_error('',$ldap->error);
}
print '</table>';

View File

@ -425,6 +425,18 @@ class UserGroup
}
/**
* \brief Creation dans l'arbre LDAP
* \param user Utilisateur qui effectue la creation
* \return int <0 si ko, >0 si ok
*/
function create_ldap($user)
{
dolibarr_syslog("UserGroup.class::create_ldap this->id=".$this->id,LOG_DEBUG);
return $this->update_ldap($user);
}
/**
* \brief Mise à jour dans l'arbre LDAP
* \param user Utilisateur qui effectue la mise à jour
@ -457,45 +469,17 @@ class UserGroup
}
if ($bind)
{
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"user");
}
else
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"inetOrgPerson");
}
$info=$this->_load_ldap_info($info);
// Champs obligatoires
$info["cn"] = trim($this->nom);
if ($this->nom) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;
else
{
$langs->load("other");
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Name"));
return -1;
}
// Champs optionnels
if ($this->note) $info["description"] = $this->note;
$info["uid"] = "Dolibarr ".$this->id;
$newdn = "cn=".$info["cn"].",".$conf->global->LDAP_GROUP_DN;
$olddn = $newdn;
if ($this->old_name) $olddn="cn=".trim($this->old_name).",".$conf->global->LDAP_CONTACT_DN;
// Definitition du DN
$dn = $conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS].",".$conf->global->LDAP_GROUP_DN;
$olddn = $dn;
// On supprime et on insère
dolibarr_syslog("UserGroup.class::update_ldap olddn=".$olddn." newdn=".$newdn);
dolibarr_syslog("User.class::update_ldap dn=".$dn." olddn=".$olddn);
$result = $ldap->delete($olddn);
$result = $ldap->add($newdn, $info);
$result = $ldap->add($dn, $info);
if ($result <= 0)
{
$this->error = ldap_errno($ldap->connection)." ".ldap_error($ldap->connection)." ".$ldap->error;
@ -558,9 +542,9 @@ class UserGroup
if ($bind)
{
$info["cn"] = trim($this->nom);
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_GROUP_DN;
$info=$this->_load_ldap_info($info);
$dn = $conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS].",".$conf->global->LDAP_GROUP_DN;
$result=$ldap->delete($dn);
return $result;
@ -574,6 +558,36 @@ class UserGroup
}
}
function _load_ldap_info($info)
{
global $conf,$langs;
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"user");
}
else
{
$info["objectclass"]=array("top",
"person",
"organizationalPerson",
"inetOrgPerson");
}
// Champs
if ($this->fullname && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->fullname;
if ($this->name && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->name;
if ($this->firstname && $conf->global->LDAP_FIELD_FIRSTNAME) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = $this->firstname;
if ($this->note) $info["description"] = $this->note;
return $info;
}
/**
* \brief Initialise le groupe avec valeurs fictives aléatoire
*/