forked from Wavyzz/dolibarr
Fix: A lot of fix on LDAP synchro.
This commit is contained in:
@@ -21,15 +21,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/adherents/adherent.class.php
|
* \file htdocs/adherents/adherent.class.php
|
||||||
\ingroup adherent
|
* \ingroup adherent
|
||||||
\brief Fichier de la classe permettant la gestion d'un adherent
|
* \brief Fichier de la classe permettant la gestion d'un adherent
|
||||||
\author Rodolphe Qiedeville
|
* \version $Id$
|
||||||
\author Jean-Louis Bergamo
|
|
||||||
\author Laurent Destailleur
|
|
||||||
\author Sebastien Di Cintio
|
|
||||||
\author Benoit Mortier
|
|
||||||
\version $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
|
||||||
@@ -1923,8 +1918,8 @@ class Adherent extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
||||||
* \param info Info string loaded by _load_ldap_info
|
* \param info Info string loaded by _load_ldap_info
|
||||||
* \param mode 0=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
|
* \param mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
|
||||||
* 1=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
|
* 1=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
|
||||||
* 2=Return key only (uid=qqq)
|
* 2=Return key only (uid=qqq)
|
||||||
* \return string DN
|
* \return string DN
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -45,16 +45,6 @@ if ($user->societe_id > 0)
|
|||||||
$socid = $user->societe_id;
|
$socid = $user->societe_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Affichage page
|
|
||||||
*/
|
|
||||||
|
|
||||||
llxHeader();
|
|
||||||
|
|
||||||
$html = new Form($db);
|
|
||||||
|
|
||||||
|
|
||||||
$adh = new Adherent($db);
|
$adh = new Adherent($db);
|
||||||
$adh->id = $rowid;
|
$adh->id = $rowid;
|
||||||
$result=$adh->fetch($rowid);
|
$result=$adh->fetch($rowid);
|
||||||
@@ -75,17 +65,22 @@ if (! $result)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Affichage onglets
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
llxHeader();
|
||||||
|
|
||||||
|
$html = new Form($db);
|
||||||
|
|
||||||
$head = member_prepare_head($adh);
|
$head = member_prepare_head($adh);
|
||||||
|
|
||||||
dol_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user');
|
dol_fiche_head($head, 'ldap', $langs->trans("Member"), 0, 'user');
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fiche en mode visu
|
|
||||||
*/
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
@@ -129,7 +124,7 @@ $langs->load("admin");
|
|||||||
// LDAP DN
|
// LDAP DN
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPMemberDn").'</td><td class="valeur">'.$conf->global->LDAP_MEMBER_DN."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPMemberDn").'</td><td class="valeur">'.$conf->global->LDAP_MEMBER_DN."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Cl<EFBFBD>
|
// LDAP Cle
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_MEMBERS."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_MEMBERS."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Server
|
// LDAP Server
|
||||||
@@ -146,9 +141,10 @@ print '</div>';
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
print_titre($langs->trans("LDAPInformationsForThisMember"));
|
|
||||||
|
|
||||||
// Affichage attributs LDAP
|
// Affichage attributs LDAP
|
||||||
|
print_titre($langs->trans("LDAPInformationsForThisMember"));
|
||||||
|
|
||||||
print '<table width="100%" class="noborder">';
|
print '<table width="100%" class="noborder">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/admin/ldap_contacts.php
|
\file htdocs/admin/ldap_contacts.php
|
||||||
\ingroup ldap
|
\ingroup ldap
|
||||||
@@ -50,7 +50,7 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
|
|||||||
|
|
||||||
if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN',$_POST["contactdn"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN',$_POST["contactdn"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS',$_POST["objectclass"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS',$_POST["objectclass"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
|
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',$_POST["fieldfullname"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',$_POST["fieldfullname"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME',$_POST["fieldfirstname"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME',$_POST["fieldfirstname"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
@@ -64,7 +64,7 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
|
|||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_ZIP',$_POST["fieldzip"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_ZIP',$_POST["fieldzip"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_TOWN',$_POST["fieldtown"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_TOWN',$_POST["fieldtown"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY',$_POST["fieldcountry"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY',$_POST["fieldcountry"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
dol_print_error($db->error());
|
dol_print_error($db->error());
|
||||||
@@ -107,7 +107,7 @@ $var=true;
|
|||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
|
print '<td colspan="4">'.$langs->trans("LDAPSynchronizeUsers").'</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
|
||||||
// DN Pour les contacts
|
// DN Pour les contacts
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
@@ -280,8 +280,9 @@ if (function_exists("ldap_connect"))
|
|||||||
$info=$object->_load_ldap_info();
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result2=$ldap->update($dn,$info,$user);
|
$result1=$ldap->delete($dn); // To be sure to delete existing records
|
||||||
$result3=$ldap->delete($dn);
|
$result2=$ldap->add($dn,$info,$user); // Now the test
|
||||||
|
$result3=$ldap->delete($dn); // Clean what we did
|
||||||
|
|
||||||
if ($result2 > 0)
|
if ($result2 > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/admin/ldap_groups.php
|
\file htdocs/admin/ldap_groups.php
|
||||||
\ingroup ldap
|
\ingroup ldap
|
||||||
@@ -43,7 +43,7 @@ if (!$user->admin)
|
|||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($_GET["action"] == 'setvalue' && $user->admin)
|
if ($_GET["action"] == 'setvalue' && $user->admin)
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
@@ -51,7 +51,7 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
|
|||||||
|
|
||||||
if (! dolibarr_set_const($db, 'LDAP_GROUP_DN',$_POST["group"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_GROUP_DN',$_POST["group"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS',$_POST["objectclass"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS',$_POST["objectclass"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
|
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',$_POST["fieldfullname"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',$_POST["fieldfullname"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_NAME',$_POST["fieldname"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION',$_POST["fielddescription"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION',$_POST["fielddescription"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
@@ -202,8 +202,9 @@ if (function_exists("ldap_connect"))
|
|||||||
$info=$object->_load_ldap_info();
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result2=$ldap->update($dn,$info,$user);
|
$result1=$ldap->delete($dn); // To be sure to delete existing records
|
||||||
$result3=$ldap->delete($dn);
|
$result2=$ldap->add($dn,$info,$user); // Now the test
|
||||||
|
$result3=$ldap->delete($dn); // Clean what we did
|
||||||
|
|
||||||
if ($result2 > 0)
|
if ($result2 > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/admin/ldap_members.php
|
\file htdocs/admin/ldap_members.php
|
||||||
\ingroup ldap adherent
|
\ingroup ldap adherent
|
||||||
@@ -43,12 +43,12 @@ if (!$user->admin)
|
|||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($_GET["action"] == 'setvalue' && $user->admin)
|
if ($_GET["action"] == 'setvalue' && $user->admin)
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS',$_POST["key"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_KEY_MEMBERS',$_POST["key"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
|
|
||||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_DN',$_POST["user"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_MEMBER_DN',$_POST["user"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS',$_POST["objectclass"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS',$_POST["objectclass"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
// Members
|
// Members
|
||||||
@@ -394,8 +394,9 @@ if (function_exists("ldap_connect"))
|
|||||||
$info=$object->_load_ldap_info();
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result2=$ldap->update($dn,$info,$user);
|
$result1=$ldap->delete($dn); // To be sure to delete existing records
|
||||||
$result3=$ldap->delete($dn);
|
$result2=$ldap->add($dn,$info,$user); // Now the test
|
||||||
|
$result3=$ldap->delete($dn); // Clean what we did
|
||||||
|
|
||||||
if ($result2 > 0)
|
if ($result2 > 0)
|
||||||
{
|
{
|
||||||
@@ -419,7 +420,7 @@ if (function_exists("ldap_connect"))
|
|||||||
print '</font><br>';
|
print '</font><br>';
|
||||||
print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
|
print $langs->trans("ErrorLDAPMakeManualTest",$conf->ldap->dir_temp).'<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
print "LDAP input file used for test:<br><br>\n";
|
print "LDAP input file used for test:<br><br>\n";
|
||||||
print nl2br($ldap->dump_content($dn,$info));
|
print nl2br($ldap->dump_content($dn,$info));
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/admin/ldap_users.php
|
\file htdocs/admin/ldap_users.php
|
||||||
\ingroup ldap
|
\ingroup ldap
|
||||||
@@ -43,7 +43,7 @@ if (!$user->admin)
|
|||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($_GET["action"] == 'setvalue' && $user->admin)
|
if ($_GET["action"] == 'setvalue' && $user->admin)
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
@@ -51,7 +51,7 @@ if ($_GET["action"] == 'setvalue' && $user->admin)
|
|||||||
|
|
||||||
if (! dolibarr_set_const($db, 'LDAP_USER_DN',$_POST["user"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_USER_DN',$_POST["user"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS',$_POST["objectclass"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS',$_POST["objectclass"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
|
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION',$_POST["filterconnection"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION',$_POST["filterconnection"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',$_POST["fieldfullname"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME',$_POST["fieldfullname"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN',$_POST["fieldlogin"],'chaine',0,'',$conf->entity)) $error++;
|
if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN',$_POST["fieldlogin"],'chaine',0,'',$conf->entity)) $error++;
|
||||||
@@ -102,7 +102,7 @@ print '<br>';
|
|||||||
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
|
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
|
||||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
|
||||||
|
|
||||||
$html=new Form($db);
|
$html=new Form($db);
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
@@ -286,7 +286,7 @@ if (function_exists("ldap_connect"))
|
|||||||
$object->initAsSpecimen();
|
$object->initAsSpecimen();
|
||||||
|
|
||||||
// TODO Mutualize code following with other ldap_xxxx.php pages
|
// TODO Mutualize code following with other ldap_xxxx.php pages
|
||||||
|
|
||||||
// Test synchro
|
// Test synchro
|
||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$result=$ldap->connect_bind();
|
$result=$ldap->connect_bind();
|
||||||
@@ -296,8 +296,9 @@ if (function_exists("ldap_connect"))
|
|||||||
$info=$object->_load_ldap_info();
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result2=$ldap->update($dn,$info,$user);
|
$result1=$ldap->delete($dn); // To be sure to delete existing records
|
||||||
$result3=$ldap->delete($dn);
|
$result2=$ldap->add($dn,$info,$user); // Now the test
|
||||||
|
$result3=$ldap->delete($dn); // Clean what we did
|
||||||
|
|
||||||
if ($result2 > 0)
|
if ($result2 > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -137,12 +137,14 @@ class Contact extends CommonObject
|
|||||||
* \param id Id du contact a mettre a jour
|
* \param id Id du contact a mettre a jour
|
||||||
* \param user Objet utilisateur qui effectue la mise a jour
|
* \param user Objet utilisateur qui effectue la mise a jour
|
||||||
* \param notrigger 0=non, 1=oui
|
* \param notrigger 0=non, 1=oui
|
||||||
* \return int <0 si erreur, >0 si ok
|
* \return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function update($id, $user=0, $notrigger=0)
|
function update($id, $user=0, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
// Nettoyage parametres
|
// Nettoyage parametres
|
||||||
@@ -155,6 +157,8 @@ class Contact extends CommonObject
|
|||||||
$this->phone_mobile=trim($this->phone_mobile);
|
$this->phone_mobile=trim($this->phone_mobile);
|
||||||
$this->fax=trim($this->fax);
|
$this->fax=trim($this->fax);
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET ";
|
||||||
if ($this->socid > 0) $sql .= " fk_soc='".addslashes($this->socid)."',";
|
if ($this->socid > 0) $sql .= " fk_soc='".addslashes($this->socid)."',";
|
||||||
if ($this->socid == -1) $sql .= " fk_soc=null,";
|
if ($this->socid == -1) $sql .= " fk_soc=null,";
|
||||||
@@ -179,32 +183,45 @@ class Contact extends CommonObject
|
|||||||
|
|
||||||
dol_syslog("Contact::update sql=".$sql,LOG_DEBUG);
|
dol_syslog("Contact::update sql=".$sql,LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if (! $result)
|
if ($result)
|
||||||
{
|
{
|
||||||
|
if (! $error && ! $notrigger)
|
||||||
|
{
|
||||||
|
// Appel des triggers
|
||||||
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
$interface=new Interfaces($this->db);
|
||||||
|
$result=$interface->run_triggers('CONTACT_MODIFY',$this,$user,$langs,$conf);
|
||||||
|
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
|
// Fin appel triggers
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -$error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
|
||||||
$this->error=$this->db->lasterror().' sql='.$sql;
|
$this->error=$this->db->lasterror().' sql='.$sql;
|
||||||
dol_syslog("Contact::update Error ".$this->error,LOG_ERR);
|
dol_syslog("Contact::update Error ".$this->error,LOG_ERR);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $notrigger)
|
|
||||||
{
|
|
||||||
// Appel des triggers
|
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
|
||||||
$interface=new Interfaces($this->db);
|
|
||||||
$result=$interface->run_triggers('CONTACT_MODIFY',$this,$user,$langs,$conf);
|
|
||||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
|
||||||
// Fin appel triggers
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
||||||
* \param info Info string loaded by _load_ldap_info
|
* \param info Info string loaded by _load_ldap_info
|
||||||
* \param mode 0=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
|
* \param mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
|
||||||
* 1=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
|
* 1=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
|
||||||
* 2=Return key only (uid=qqq)
|
* 2=Return key only (uid=qqq)
|
||||||
* \return string DN
|
* \return string DN
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2006 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2006 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -39,6 +39,11 @@ $contactid = isset($_GET["id"])?$_GET["id"]:'';
|
|||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'contact', $contactid, 'socpeople');
|
$result = restrictedArea($user, 'contact', $contactid, 'socpeople');
|
||||||
|
|
||||||
|
$contact = new Contact($db);
|
||||||
|
$contact->fetch($_GET["id"], $user);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@@ -48,18 +53,11 @@ llxHeader();
|
|||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
|
|
||||||
$contact = new Contact($db);
|
|
||||||
$contact->fetch($_GET["id"], $user);
|
|
||||||
|
|
||||||
|
|
||||||
$head = contact_prepare_head($contact);
|
$head = contact_prepare_head($contact);
|
||||||
|
|
||||||
dol_fiche_head($head, 'ldap', $langs->trans("Contact"), 0, 'contact');
|
dol_fiche_head($head, 'ldap', $langs->trans("Contact"), 0, 'contact');
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fiche en mode visu
|
|
||||||
*/
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
@@ -94,7 +92,7 @@ print '</td></tr>';
|
|||||||
// LDAP DN
|
// LDAP DN
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPContactDn").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_CONTACT_DN."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPContactDn").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_CONTACT_DN."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Cl<EFBFBD>
|
// LDAP Cle
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_KEY_CONTACTS."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur" colspan="3">'.$conf->global->LDAP_KEY_CONTACTS."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Server
|
// LDAP Server
|
||||||
@@ -109,9 +107,9 @@ print '</div>';
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
|
// Affichage attributs LDAP
|
||||||
print_titre($langs->trans("LDAPInformationsForThisContact"));
|
print_titre($langs->trans("LDAPInformationsForThisContact"));
|
||||||
|
|
||||||
// Affichage attributs LDAP
|
|
||||||
print '<table width="100%" class="noborder">';
|
print '<table width="100%" class="noborder">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
|
|||||||
@@ -135,10 +135,15 @@ class InterfaceLdapsynchro
|
|||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$ldap->connect_bind();
|
$ldap->connect_bind();
|
||||||
|
|
||||||
$info=$object->_load_ldap_info();
|
$oldobject=$object; // TODO Get oldobject
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error="ErrorLDAP"." ".$ldap->error;
|
$this->error="ErrorLDAP"." ".$ldap->error;
|
||||||
@@ -200,10 +205,15 @@ class InterfaceLdapsynchro
|
|||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$ldap->connect_bind();
|
$ldap->connect_bind();
|
||||||
|
|
||||||
$info=$object->_load_ldap_info();
|
$oldobject=$object; // TODO Get oldobject
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error="ErrorLDAP"." ".$ldap->error;
|
$this->error="ErrorLDAP"." ".$ldap->error;
|
||||||
@@ -258,10 +268,15 @@ class InterfaceLdapsynchro
|
|||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$ldap->connect_bind();
|
$ldap->connect_bind();
|
||||||
|
|
||||||
|
$oldobject=$object; // TODO Get oldobject
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
$info=$object->_load_ldap_info();
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error="ErrorLDAP"." ".$ldap->error;
|
$this->error="ErrorLDAP"." ".$ldap->error;
|
||||||
@@ -320,10 +335,15 @@ class InterfaceLdapsynchro
|
|||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$ldap->connect_bind();
|
$ldap->connect_bind();
|
||||||
|
|
||||||
$info=$object->_load_ldap_info();
|
$oldobject=$object; // TODO Get oldobject
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error="ErrorLDAP"." ".$ldap->error;
|
$this->error="ErrorLDAP"." ".$ldap->error;
|
||||||
@@ -347,10 +367,15 @@ class InterfaceLdapsynchro
|
|||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$ldap->connect_bind();
|
$ldap->connect_bind();
|
||||||
|
|
||||||
$info=$object->_load_ldap_info();
|
$oldobject=$object; // TODO Get oldobject
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error="ErrorLDAP"." ".$ldap->error;
|
$this->error="ErrorLDAP"." ".$ldap->error;
|
||||||
@@ -367,10 +392,15 @@ class InterfaceLdapsynchro
|
|||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$ldap->connect_bind();
|
$ldap->connect_bind();
|
||||||
|
|
||||||
$info=$object->_load_ldap_info();
|
$oldobject=$object; // TODO Get oldobject
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error="ErrorLDAP"." ".$ldap->error;
|
$this->error="ErrorLDAP"." ".$ldap->error;
|
||||||
@@ -412,10 +442,15 @@ class InterfaceLdapsynchro
|
|||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$ldap->connect_bind();
|
$ldap->connect_bind();
|
||||||
|
|
||||||
$info=$object->_load_ldap_info();
|
$oldobject=$object; // TODO Get oldobject
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
|
$info=$object->_load_ldap_info();
|
||||||
$dn=$object->_load_ldap_dn($info);
|
$dn=$object->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error="ErrorLDAP"." ".$ldap->error;
|
$this->error="ErrorLDAP"." ".$ldap->error;
|
||||||
|
|||||||
@@ -23,5 +23,6 @@ LDAPFieldLastSubscriptionDate=Last subscription date
|
|||||||
LDAPFieldLastSubscriptionAmount=Last subscription amount
|
LDAPFieldLastSubscriptionAmount=Last subscription amount
|
||||||
SynchronizeDolibarr2Ldap=Synchronize user (Dolibarr -> LDAP)
|
SynchronizeDolibarr2Ldap=Synchronize user (Dolibarr -> LDAP)
|
||||||
UserSynchronized=User synchronized
|
UserSynchronized=User synchronized
|
||||||
|
GroupSynchronized=Group synchronized
|
||||||
ForceSynchronize=Force synchronizing Dolibarr -> LDAP
|
ForceSynchronize=Force synchronizing Dolibarr -> LDAP
|
||||||
ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility.
|
ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility.
|
||||||
@@ -23,5 +23,6 @@ LDAPFieldLastSubscriptionDate=Date dernière adhésion
|
|||||||
LDAPFieldLastSubscriptionAmount=Montant dernière adhésion
|
LDAPFieldLastSubscriptionAmount=Montant dernière adhésion
|
||||||
SynchronizeDolibarr2Ldap=Synchroniser utilisateur (Dolibarr -> LDAP)
|
SynchronizeDolibarr2Ldap=Synchroniser utilisateur (Dolibarr -> LDAP)
|
||||||
UserSynchronized=Utilisateur synchronisé
|
UserSynchronized=Utilisateur synchronisé
|
||||||
|
GroupSynchronized=Groupe synchronisé
|
||||||
ForceSynchronize=Forcer synchro Dolibarr -> LDAP
|
ForceSynchronize=Forcer synchro Dolibarr -> LDAP
|
||||||
ErrorFailedToReadLDAP=Echec de la lecture de l'annuaire LDAP. Vérifier la configuration du module LDAP et l'accessibilité de l'annuaire.
|
ErrorFailedToReadLDAP=Echec de la lecture de l'annuaire LDAP. Vérifier la configuration du module LDAP et l'accessibilité de l'annuaire.
|
||||||
@@ -2620,11 +2620,11 @@ function dol_entity_decode($stringhtml,$pagecodeto='UTF-8')
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Check if a string is a correct iso string
|
* \brief Check if a string is a correct iso string
|
||||||
If not, it will we considered not HTML encoded even if it is by FPDF.
|
* If not, it will we considered not HTML encoded even if it is by FPDF.
|
||||||
\remarks Example, if string contains euro symbol that has ascii code 128.
|
* \remarks Example, if string contains euro symbol that has ascii code 128.
|
||||||
\param s String to check
|
* \param s String to check
|
||||||
\return int 0 if bad iso, 1 if good iso
|
* \return int 0 if bad iso, 1 if good iso
|
||||||
*/
|
*/
|
||||||
function dol_string_is_good_iso($s)
|
function dol_string_is_good_iso($s)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -388,50 +388,6 @@ class Ldap
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Mise <20> jour dans l'arbre LDAP
|
|
||||||
* \param dn DN
|
|
||||||
* \param info Tableau info
|
|
||||||
* \param user Objet user qui fait l'op<6F>ration
|
|
||||||
* \return int <0 si ko, >0 si ok
|
|
||||||
* \remarks Ldap object connect and bind must have been done
|
|
||||||
*/
|
|
||||||
function update($dn,$info,$user,$olddn='')
|
|
||||||
{
|
|
||||||
global $conf, $langs;
|
|
||||||
|
|
||||||
if (! $this->connection)
|
|
||||||
{
|
|
||||||
$this->error=$langs->trans("NotConnected");
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
if (! $this->bind)
|
|
||||||
{
|
|
||||||
$this->error=$langs->trans("NotConnected");
|
|
||||||
return -3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! $olddn) $olddn=$dn;
|
|
||||||
|
|
||||||
dol_syslog("Ldap::update dn=".$dn." olddn=".$olddn);
|
|
||||||
|
|
||||||
// On supprime et on ins<6E>re
|
|
||||||
$result = $this->delete($olddn);
|
|
||||||
$result = $this->add($dn, $info, $user);
|
|
||||||
if ($result <= 0)
|
|
||||||
{
|
|
||||||
$this->error = ldap_errno($this->connection)." ".ldap_error($this->connection)." ".$this->error;
|
|
||||||
dol_syslog("Ldap::update ".$this->error,LOG_ERR);
|
|
||||||
//print_r($info);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_syslog("Ldap::update done successfully");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Checks a username and password - does this by logging on to the
|
* \brief Checks a username and password - does this by logging on to the
|
||||||
@@ -482,8 +438,9 @@ class Ldap
|
|||||||
* \brief Add a LDAP entry
|
* \brief Add a LDAP entry
|
||||||
* \param dn DN entry key
|
* \param dn DN entry key
|
||||||
* \param info Attributes array
|
* \param info Attributes array
|
||||||
* \param user Objet utilisateru qui cr<63>e
|
* \param user Objet user that create
|
||||||
* \return int <0 si KO, >0 si OK
|
* \return int <0 if KO, >0 if OK
|
||||||
|
* \remarks Ldap object connect and bind must have been done
|
||||||
*/
|
*/
|
||||||
function add($dn, $info, $user)
|
function add($dn, $info, $user)
|
||||||
{
|
{
|
||||||
@@ -491,6 +448,18 @@ class Ldap
|
|||||||
|
|
||||||
dol_syslog("Ldap::add dn=".$dn." info=".join(',',$info));
|
dol_syslog("Ldap::add dn=".$dn." info=".join(',',$info));
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if (! $this->connection)
|
||||||
|
{
|
||||||
|
$this->error="NotConnected";
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
if (! $this->bind)
|
||||||
|
{
|
||||||
|
$this->error="NotConnected";
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
// Encode to LDAP page code
|
// Encode to LDAP page code
|
||||||
$dn=$this->convFromOutputCharset($dn,$this->ldapcharset);
|
$dn=$this->convFromOutputCharset($dn,$this->ldapcharset);
|
||||||
foreach($info as $key => $val)
|
foreach($info as $key => $val)
|
||||||
@@ -516,10 +485,116 @@ class Ldap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Modify a LDAP entry
|
||||||
|
* \param dn DN entry key
|
||||||
|
* \param info Attributes array
|
||||||
|
* \param user Objet user that modify
|
||||||
|
* \return int <0 if KO, >0 if OK
|
||||||
|
* \remarks Ldap object connect and bind must have been done
|
||||||
|
*/
|
||||||
|
function modify($dn, $info, $user)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
dol_syslog("Ldap::modify dn=".$dn." info=".join(',',$info));
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if (! $this->connection)
|
||||||
|
{
|
||||||
|
$this->error="NotConnected";
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
if (! $this->bind)
|
||||||
|
{
|
||||||
|
$this->error="NotConnected";
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode to LDAP page code
|
||||||
|
$dn=$this->convFromOutputCharset($dn,$this->ldapcharset);
|
||||||
|
foreach($info as $key => $val)
|
||||||
|
{
|
||||||
|
if (! is_array($val)) $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dump($dn,$info);
|
||||||
|
|
||||||
|
//print_r($info);
|
||||||
|
$result=@ldap_modify($this->connection, $dn, $info);
|
||||||
|
|
||||||
|
if ($result)
|
||||||
|
{
|
||||||
|
dol_syslog("Ldap::modify successfull", LOG_DEBUG);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=@ldap_error($this->connection);
|
||||||
|
dol_syslog("Ldap::modify failed: ".$this->error, LOG_ERR);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Modify a LDAP entry (to use if dn != olddn)
|
||||||
|
* \param dn DN entry key
|
||||||
|
* \param info Attributes array
|
||||||
|
* \param user Objet user that delete
|
||||||
|
* \param olddn Old DN entry key (before update)
|
||||||
|
* \return int <0 if KO, >0 if OK
|
||||||
|
* \remarks Ldap object connect and bind must have been done
|
||||||
|
*/
|
||||||
|
function update($dn,$info,$user,$olddn)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
dol_syslog("Ldap::update dn=".$dn." olddn=".$olddn);
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if (! $this->connection)
|
||||||
|
{
|
||||||
|
$this->error="NotConnected";
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
if (! $this->bind)
|
||||||
|
{
|
||||||
|
$this->error="NotConnected";
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $olddn || $olddn != $dn)
|
||||||
|
{
|
||||||
|
// This case is not used for the moment
|
||||||
|
$result = $this->add($dn, $info, $user);
|
||||||
|
if ($result > 0 && $olddn && $olddn != $dn) $result = $this->delete($olddn); // If add fails, we do not try to delete old one
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result = $this->delete($olddn);
|
||||||
|
$result = $this->add($dn, $info, $user);
|
||||||
|
//$result = $this->modify($dn, $info, $user); // TODO Must use modify instead of delete/add when olddn is received (for the moment olddn is dn)
|
||||||
|
}
|
||||||
|
if ($result <= 0)
|
||||||
|
{
|
||||||
|
$this->error = ldap_errno($this->connection)." ".ldap_error($this->connection)." ".$this->error;
|
||||||
|
dol_syslog("Ldap::update ".$this->error,LOG_ERR);
|
||||||
|
//print_r($info);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dol_syslog("Ldap::update done successfully");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Delete a LDAP entry
|
* \brief Delete a LDAP entry
|
||||||
* \param dn DN entry key
|
* \param dn DN entry key
|
||||||
* \return int <0 si KO, >0 si OK
|
* \return int <0 si KO, >0 si OK
|
||||||
|
* \remarks Ldap object connect and bind must have been done
|
||||||
*/
|
*/
|
||||||
function delete($dn)
|
function delete($dn)
|
||||||
{
|
{
|
||||||
@@ -527,6 +602,18 @@ class Ldap
|
|||||||
|
|
||||||
dol_syslog("Ldap::delete Delete LDAP entry dn=".$dn);
|
dol_syslog("Ldap::delete Delete LDAP entry dn=".$dn);
|
||||||
|
|
||||||
|
// Check parameters
|
||||||
|
if (! $this->connection)
|
||||||
|
{
|
||||||
|
$this->error="NotConnected";
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
if (! $this->bind)
|
||||||
|
{
|
||||||
|
$this->error="NotConnected";
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
// Encode to LDAP page code
|
// Encode to LDAP page code
|
||||||
$dn=$this->convFromOutputCharset($dn,$this->ldapcharset);
|
$dn=$this->convFromOutputCharset($dn,$this->ldapcharset);
|
||||||
|
|
||||||
@@ -1101,32 +1188,32 @@ class Ldap
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Convert a string into output/memory charset
|
* \brief Convert a string into output/memory charset
|
||||||
* \param str String to convert
|
* \param str String to convert
|
||||||
* \param pagecodefrom Page code of src string
|
* \param pagecodefrom Page code of src string
|
||||||
* \return string Converted string
|
* \return string Converted string
|
||||||
*/
|
*/
|
||||||
function convToOutputCharset($str,$pagecodefrom='UTF-8')
|
function convToOutputCharset($str,$pagecodefrom='UTF-8')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
if ($pagecodefrom == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') $str=utf8_encode($str);
|
if ($pagecodefrom == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') $str=utf8_encode($str);
|
||||||
if ($pagecodefrom == 'UTF-8' && $conf->file->character_set_client == 'ISO-8859-1') $str=utf8_decode($str);
|
if ($pagecodefrom == 'UTF-8' && $conf->file->character_set_client == 'ISO-8859-1') $str=utf8_decode($str);
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Convert a string from output/memory charset
|
* \brief Convert a string from output/memory charset
|
||||||
* \param str String to convert
|
* \param str String to convert
|
||||||
* \param pagecodeto Page code for result string
|
* \param pagecodeto Page code for result string
|
||||||
* \return string Converted string
|
* \return string Converted string
|
||||||
*/
|
*/
|
||||||
function convFromOutputCharset($str,$pagecodeto='UTF-8')
|
function convFromOutputCharset($str,$pagecodeto='UTF-8')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
if ($pagecodeto == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') $str=utf8_decode($str);
|
if ($pagecodeto == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') $str=utf8_decode($str);
|
||||||
if ($pagecodeto == 'UTF-8' && $conf->file->character_set_client == 'ISO-8859-1') $str=utf8_encode($str);
|
if ($pagecodeto == 'UTF-8' && $conf->file->character_set_client == 'ISO-8859-1') $str=utf8_encode($str);
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,12 @@ function ldap_prepare_head()
|
|||||||
// Onglets
|
// Onglets
|
||||||
$head=array();
|
$head=array();
|
||||||
$h = 0;
|
$h = 0;
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/admin/ldap.php";
|
$head[$h][0] = DOL_URL_ROOT."/admin/ldap.php";
|
||||||
$head[$h][1] = $langs->trans("LDAPGlobalParameters");
|
$head[$h][1] = $langs->trans("LDAPGlobalParameters");
|
||||||
$head[$h][2] = 'ldap';
|
$head[$h][2] = 'ldap';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
if ($conf->global->LDAP_SYNCHRO_ACTIVE)
|
if ($conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||||
{
|
{
|
||||||
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_users.php";
|
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_users.php";
|
||||||
@@ -58,7 +58,7 @@ function ldap_prepare_head()
|
|||||||
$head[$h][2] = 'groups';
|
$head[$h][2] = 'groups';
|
||||||
$h++;
|
$h++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->societe->enabled && $conf->global->LDAP_CONTACT_ACTIVE)
|
if ($conf->societe->enabled && $conf->global->LDAP_CONTACT_ACTIVE)
|
||||||
{
|
{
|
||||||
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_contacts.php";
|
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_contacts.php";
|
||||||
@@ -66,7 +66,7 @@ function ldap_prepare_head()
|
|||||||
$head[$h][2] = 'contacts';
|
$head[$h][2] = 'contacts';
|
||||||
$h++;
|
$h++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->adherent->enabled && $conf->global->LDAP_MEMBER_ACTIVE)
|
if ($conf->adherent->enabled && $conf->global->LDAP_MEMBER_ACTIVE)
|
||||||
{
|
{
|
||||||
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_members.php";
|
$head[$h][0] = DOL_URL_ROOT."/admin/ldap_members.php";
|
||||||
@@ -86,7 +86,7 @@ function show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass)
|
|||||||
{
|
{
|
||||||
global $langs, $conf, $user;
|
global $langs, $conf, $user;
|
||||||
//print 'key='.$key.' dn='.$dn.' objectclass='.$objectclass;
|
//print 'key='.$key.' dn='.$dn.' objectclass='.$objectclass;
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
if (! function_exists("ldap_connect"))
|
if (! function_exists("ldap_connect"))
|
||||||
{
|
{
|
||||||
@@ -122,7 +122,7 @@ function show_ldap_test_button($butlabel,$testlabel,$key,$dn,$objectclass)
|
|||||||
function show_ldap_content($result,$level,$count,$var,$hide=0)
|
function show_ldap_content($result,$level,$count,$var,$hide=0)
|
||||||
{
|
{
|
||||||
global $bc, $conf;
|
global $bc, $conf;
|
||||||
|
|
||||||
$count++;
|
$count++;
|
||||||
if ($count > 1000) return -1; // To avoid infinite loop
|
if ($count > 1000) return -1; // To avoid infinite loop
|
||||||
if (! is_array($result)) return -1;
|
if (! is_array($result)) return -1;
|
||||||
@@ -132,16 +132,16 @@ function show_ldap_content($result,$level,$count,$var,$hide=0)
|
|||||||
if ("$key" == "objectclass") continue;
|
if ("$key" == "objectclass") continue;
|
||||||
if ("$key" == "count") continue;
|
if ("$key" == "count") continue;
|
||||||
if ("$key" == "dn") continue;
|
if ("$key" == "dn") continue;
|
||||||
|
|
||||||
if ("$val" == "objectclass") continue;
|
if ("$val" == "objectclass") continue;
|
||||||
if ("$val" == $lastkey[$level]) continue;
|
if ("$val" == $lastkey[$level]) continue;
|
||||||
|
|
||||||
$lastkey[$level]=$key;
|
$lastkey[$level]=$key;
|
||||||
|
|
||||||
if (is_array($val))
|
if (is_array($val))
|
||||||
{
|
{
|
||||||
$hide=0;
|
$hide=0;
|
||||||
if (! is_numeric($key))
|
if (! is_numeric($key))
|
||||||
{
|
{
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
print '<tr '.$bc[$var].'><td>';
|
print '<tr '.$bc[$var].'><td>';
|
||||||
@@ -153,8 +153,9 @@ function show_ldap_content($result,$level,$count,$var,$hide=0)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($hide) print eregi_replace('.','*',$val);
|
$newstring=@htmlentities($val,ENT_COMPAT,'UTF-8'); // Make entity encoding
|
||||||
else print $val;
|
if ($hide) print eregi_replace('.','*',$newstring);
|
||||||
|
else print $newstring;
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1414,11 +1414,11 @@ class User extends CommonObject
|
|||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $this->db->error();
|
print $this->db->error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1566,8 +1566,8 @@ class User extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
||||||
* \param info Info string loaded by _load_ldap_info
|
* \param info Info string loaded by _load_ldap_info
|
||||||
* \param mode 0=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
|
* \param mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
|
||||||
* 1=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
|
* 1=
|
||||||
* 2=Return key only (uid=qqq)
|
* 2=Return key only (uid=qqq)
|
||||||
* \return string DN
|
* \return string DN
|
||||||
*/
|
*/
|
||||||
@@ -1581,6 +1581,11 @@ class User extends CommonObject
|
|||||||
return $dn;
|
return $dn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Initialise tableau info (tableau des attributs LDAP)
|
||||||
|
* \return array Tableau info des attributs
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialise tableau info (tableau des attributs LDAP)
|
* \brief Initialise tableau info (tableau des attributs LDAP)
|
||||||
|
|||||||
@@ -144,8 +144,8 @@ if ($_POST["action"] == 'update')
|
|||||||
$editgroup = new Usergroup($db, $_GET["id"]);
|
$editgroup = new Usergroup($db, $_GET["id"]);
|
||||||
$editgroup->fetch($_GET["id"]);
|
$editgroup->fetch($_GET["id"]);
|
||||||
|
|
||||||
$editgroup->nom = $_POST["group"];
|
$editgroup->nom = trim($_POST["group"]);
|
||||||
$editgroup->note = $_POST["note"];
|
$editgroup->note = dol_htmlcleanlastbr($_POST["note"]);
|
||||||
|
|
||||||
$ret=$editgroup->update();
|
$ret=$editgroup->update();
|
||||||
|
|
||||||
|
|||||||
@@ -42,33 +42,62 @@ if ($user->societe_id > 0)
|
|||||||
$socid = $user->societe_id;
|
$socid = $user->societe_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Affichage page
|
|
||||||
*/
|
|
||||||
|
|
||||||
llxHeader();
|
|
||||||
|
|
||||||
$form = new Form($db);
|
|
||||||
|
|
||||||
$fgroup = new Usergroup($db, $_GET["id"]);
|
$fgroup = new Usergroup($db, $_GET["id"]);
|
||||||
$fgroup->fetch($_GET["id"]);
|
$fgroup->fetch($_GET["id"]);
|
||||||
$fgroup->getrights();
|
$fgroup->getrights();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Affichage onglets
|
* Actions
|
||||||
*/
|
*/
|
||||||
$head = group_prepare_head($fgroup);
|
|
||||||
|
|
||||||
dol_fiche_head($head, 'ldap', $langs->trans("Group"));
|
if ($_GET["action"] == 'dolibarr2ldap')
|
||||||
|
{
|
||||||
|
$message="";
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$ldap=new Ldap();
|
||||||
|
$result=$ldap->connect_bind();
|
||||||
|
|
||||||
|
$oldobject=$fgroup; // TODO Get oldobject
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
|
$info=$fgroup->_load_ldap_info();
|
||||||
|
$dn=$fgroup->_load_ldap_dn($info);
|
||||||
|
$result=$ldap->add($dn,$info,$user);
|
||||||
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
|
|
||||||
|
if ($result >= 0)
|
||||||
|
{
|
||||||
|
$message.='<div class="ok">'.$langs->trans("GroupSynchronized").'</div>';
|
||||||
|
$db->commit();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$message.='<div class="error">'.$ldap->error.'</div>';
|
||||||
|
$db->rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fiche en mode visu
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
llxHeader();
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
|
|
||||||
|
$head = group_prepare_head($fgroup);
|
||||||
|
|
||||||
|
dol_fiche_head($head, 'ldap', $langs->trans("Group"));
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
@@ -97,7 +126,7 @@ $langs->load("admin");
|
|||||||
// LDAP DN
|
// LDAP DN
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPGroupDn").'</td><td class="valeur">'.$conf->global->LDAP_GROUP_DN."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPGroupDn").'</td><td class="valeur">'.$conf->global->LDAP_GROUP_DN."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Cl<EFBFBD>
|
// LDAP Cle
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_GROUPS."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_GROUPS."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Server
|
// LDAP Server
|
||||||
@@ -109,12 +138,29 @@ print "</table>\n";
|
|||||||
|
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
print '<br>';
|
if ($message) { print $message; }
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Barre d'actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
|
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap')
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$fgroup->id.'&action=dolibarr2ldap">'.$langs->trans("ForceSynchronize").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</div>\n";
|
||||||
|
|
||||||
|
if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') print "<br>\n";
|
||||||
|
|
||||||
|
|
||||||
print_titre($langs->trans("LDAPInformationsForThisGroup"));
|
|
||||||
|
|
||||||
// Affichage attributs LDAP
|
// Affichage attributs LDAP
|
||||||
|
print_titre($langs->trans("LDAPInformationsForThisGroup"));
|
||||||
|
|
||||||
print '<table width="100%" class="noborder">';
|
print '<table width="100%" class="noborder">';
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
|
|||||||
@@ -61,9 +61,15 @@ if ($_GET["action"] == 'dolibarr2ldap')
|
|||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$result=$ldap->connect_bind();
|
$result=$ldap->connect_bind();
|
||||||
|
|
||||||
|
$oldobject=$fuser; // TODO Get oldobject
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
$info=$fuser->_load_ldap_info();
|
$info=$fuser->_load_ldap_info();
|
||||||
$dn=$fuser->_load_ldap_dn($info);
|
$dn=$fuser->_load_ldap_dn($info);
|
||||||
$result=$ldap->update($dn,$info,$user); // Marche en creation LDAP et mise a jour
|
$result=$ldap->add($dn,$info,$user);
|
||||||
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
|
|
||||||
if ($result >= 0)
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
@@ -146,7 +152,7 @@ if ($conf->global->LDAP_SERVER_TYPE == "activedirectory")
|
|||||||
// LDAP DN
|
// LDAP DN
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPUserDn").'</td><td class="valeur">'.$conf->global->LDAP_USER_DN."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPUserDn").'</td><td class="valeur">'.$conf->global->LDAP_USER_DN."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Cl<EFBFBD>
|
// LDAP Cle
|
||||||
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_USERS."</td></tr>\n";
|
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_USERS."</td></tr>\n";
|
||||||
|
|
||||||
// LDAP Server
|
// LDAP Server
|
||||||
|
|||||||
@@ -525,8 +525,8 @@ class UserGroup extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
* \brief Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
|
||||||
* \param info Info string loaded by _load_ldap_info
|
* \param info Info string loaded by _load_ldap_info
|
||||||
* \param mode 0=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
|
* \param mode 0=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
|
||||||
* 1=Return full DN (uid=qqq,ou=xxx,dc=aaa,dc=bbb)
|
* 1=Return DN without key inside (ou=xxx,dc=aaa,dc=bbb)
|
||||||
* 2=Return key only (uid=qqq)
|
* 2=Return key only (uid=qqq)
|
||||||
* \return string DN
|
* \return string DN
|
||||||
*/
|
*/
|
||||||
@@ -534,7 +534,7 @@ class UserGroup extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
$dn='';
|
$dn='';
|
||||||
if ($mode==0) $dn=$conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS].",".$conf->global->LDAP_USER_DN;
|
if ($mode==0) $dn=$conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS].",".$conf->global->LDAP_GROUP_DN;
|
||||||
if ($mode==1) $dn=$conf->global->LDAP_GROUP_DN;
|
if ($mode==1) $dn=$conf->global->LDAP_GROUP_DN;
|
||||||
if ($mode==2) $dn=$conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS];
|
if ($mode==2) $dn=$conf->global->LDAP_KEY_GROUPS."=".$info[$conf->global->LDAP_KEY_GROUPS];
|
||||||
return $dn;
|
return $dn;
|
||||||
|
|||||||
@@ -122,10 +122,16 @@ if ($resql)
|
|||||||
|
|
||||||
print $langs->transnoentities("UpdateMember")." rowid=".$member->id." ".$member->fullname;
|
print $langs->transnoentities("UpdateMember")." rowid=".$member->id." ".$member->fullname;
|
||||||
|
|
||||||
$info=$member->_load_ldap_info();
|
$oldobject=$member;
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
|
$info=$member->_load_ldap_info();
|
||||||
$dn=$member->_load_ldap_dn($info);
|
$dn=$member->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->add($dn,$info,$user); // Wil fail if already exists
|
||||||
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
print " - ".$langs->transnoentities("OK");
|
print " - ".$langs->transnoentities("OK");
|
||||||
|
|||||||
@@ -86,10 +86,16 @@ if ($resql)
|
|||||||
|
|
||||||
print $langs->trans("UpdateContact")." rowid=".$contact->id." ".$contact->getFullName($langs);
|
print $langs->trans("UpdateContact")." rowid=".$contact->id." ".$contact->getFullName($langs);
|
||||||
|
|
||||||
|
$oldobject=$contact;
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
$info=$contact->_load_ldap_info();
|
$info=$contact->_load_ldap_info();
|
||||||
$dn=$contact->_load_ldap_dn($info);
|
$dn=$contact->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->add($dn,$info,$user); // Wil fail if already exists
|
||||||
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
print " - ".$langs->trans("OK");
|
print " - ".$langs->trans("OK");
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
// Test si mode batch
|
// Test si mode batch
|
||||||
$sapi_type = php_sapi_name();
|
$sapi_type = php_sapi_name();
|
||||||
$script_file=__FILE__;
|
$script_file=__FILE__;
|
||||||
if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1];
|
if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1];
|
||||||
|
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||||
@@ -37,7 +37,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($argv[1]) || ! $argv[1]) {
|
if (! isset($argv[1]) || ! $argv[1]) {
|
||||||
print "Usage: $script_file now\n";
|
print "Usage: $script_file now\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$now=$argv[1];
|
$now=$argv[1];
|
||||||
@@ -59,7 +59,7 @@ print "***** $script_file ($version) *****\n";
|
|||||||
if (! $conf->global->LDAP_SYNCHRO_ACTIVE)
|
if (! $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||||
{
|
{
|
||||||
print $langs->trans("LDAPSynchronizationNotSetupInDolibarr");
|
print $langs->trans("LDAPSynchronizationNotSetupInDolibarr");
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ if ($resql)
|
|||||||
|
|
||||||
$ldap=new Ldap();
|
$ldap=new Ldap();
|
||||||
$ldap->connect_bind();
|
$ldap->connect_bind();
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$ldap->error="";
|
$ldap->error="";
|
||||||
@@ -84,13 +84,19 @@ if ($resql)
|
|||||||
$fgroup = new UserGroup($db);
|
$fgroup = new UserGroup($db);
|
||||||
$fgroup->id = $obj->rowid;
|
$fgroup->id = $obj->rowid;
|
||||||
$fgroup->fetch($fgroup->id);
|
$fgroup->fetch($fgroup->id);
|
||||||
|
|
||||||
print $langs->trans("UpdateGroup")." rowid=".$fgroup->id." ".$fgroup->nom;
|
print $langs->trans("UpdateGroup")." rowid=".$fgroup->id." ".$fgroup->nom;
|
||||||
|
|
||||||
$info=$fgroup->_load_ldap_info();
|
$oldobject=$fgroup;
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
|
$info=$fgroup->_load_ldap_info();
|
||||||
$dn=$fgroup->_load_ldap_dn($info);
|
$dn=$fgroup->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->add($dn,$info,$user); // Wil fail if already exists
|
||||||
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
print " - ".$langs->trans("OK");
|
print " - ".$langs->trans("OK");
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
// Test si mode batch
|
// Test si mode batch
|
||||||
$sapi_type = php_sapi_name();
|
$sapi_type = php_sapi_name();
|
||||||
$script_file=__FILE__;
|
$script_file=__FILE__;
|
||||||
if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1];
|
if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1];
|
||||||
|
|
||||||
if (substr($sapi_type, 0, 3) == 'cgi') {
|
if (substr($sapi_type, 0, 3) == 'cgi') {
|
||||||
@@ -37,7 +37,7 @@ if (substr($sapi_type, 0, 3) == 'cgi') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! isset($argv[1]) || ! $argv[1]) {
|
if (! isset($argv[1]) || ! $argv[1]) {
|
||||||
print "Usage: $script_file now\n";
|
print "Usage: $script_file now\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$now=$argv[1];
|
$now=$argv[1];
|
||||||
@@ -59,7 +59,7 @@ print "***** $script_file ($version) *****\n";
|
|||||||
if (! $conf->global->LDAP_SYNCHRO_ACTIVE)
|
if (! $conf->global->LDAP_SYNCHRO_ACTIVE)
|
||||||
{
|
{
|
||||||
print $langs->trans("LDAPSynchronizationNotSetupInDolibarr");
|
print $langs->trans("LDAPSynchronizationNotSetupInDolibarr");
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -84,13 +84,19 @@ if ($resql)
|
|||||||
$fuser = new User($db);
|
$fuser = new User($db);
|
||||||
$fuser->id = $obj->rowid;
|
$fuser->id = $obj->rowid;
|
||||||
$fuser->fetch();
|
$fuser->fetch();
|
||||||
|
|
||||||
print $langs->trans("UpdateUser")." rowid=".$fuser->id." ".$fuser->fullname;
|
print $langs->trans("UpdateUser")." rowid=".$fuser->id." ".$fuser->fullname;
|
||||||
|
|
||||||
$info=$fuser->_load_ldap_info();
|
$oldobject=$fuser;
|
||||||
|
|
||||||
|
$oldinfo=$oldobject->_load_ldap_info();
|
||||||
|
$olddn=$oldobject->_load_ldap_dn($oldinfo);
|
||||||
|
|
||||||
|
$info=$fuser->_load_ldap_info();
|
||||||
$dn=$fuser->_load_ldap_dn($info);
|
$dn=$fuser->_load_ldap_dn($info);
|
||||||
|
|
||||||
$result=$ldap->update($dn,$info,$user);
|
$result=$ldap->add($dn,$info,$user); // Wil fail if already exists
|
||||||
|
$result=$ldap->update($dn,$info,$user,$olddn);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
print " - ".$langs->trans("OK");
|
print " - ".$langs->trans("OK");
|
||||||
|
|||||||
Reference in New Issue
Block a user