diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php
index 36a16fa6c63..30f8090eb01 100644
--- a/htdocs/adherents/adherent.class.php
+++ b/htdocs/adherents/adherent.class.php
@@ -1891,7 +1891,7 @@ class Adherent
/*
- * \brief Retourne chaine dn dans l'annuaire LDAP
+ * \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs
*/
function _load_ldap_info()
@@ -1900,26 +1900,15 @@ class Adherent
$info=array();
- if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
- {
- $info["objectclass"]=array("top",
- "person",
- "organizationalPerson",
- "user");
- }
- else
- {
- $info["objectclass"]=array("top",
- "person",
- "organizationalPerson",
- "inetOrgPerson");
- }
-
+ // Object classes
+ $info["objectclass"]=split(',',$conf->global->LDAP_MEMBER_OBJECT_CLASS);
+
// 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->pass && $conf->global->LDAP_FIELD_PASSWORD) $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypté
if ($this->poste && $conf->global->LDAP_FIELD_TITLE) $info[$conf->global->LDAP_FIELD_TITLE] = $this->poste;
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;
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index 08d5315dc6c..914773dfb8f 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -99,128 +99,128 @@ llxHeader();
if ($facid > 0)
{
- $facture = new Facture($db);
-
- if ($facture->fetch($facid))
- {
- $facref = sanitize_string($facture->ref);
-
- $upload_dir = $conf->facture->dir_output.'/'.$facref;
-
- $societe = new Societe($db);
- $societe->fetch($facture->socid);
+ $facture = new Facture($db);
- $head = facture_prepare_head($facture);
- dolibarr_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'));
-
- // Construit liste des fichiers
- clearstatcache();
-
- $totalsize=0;
- $filearray=array();
-
- $errorlevel=error_reporting();
- error_reporting(0);
- $handle=opendir($upload_dir);
- error_reporting($errorlevel);
- if ($handle)
- {
- $i=0;
- while (($file = readdir($handle))!==false)
- {
- if (! is_dir($dir.$file)
- && ! eregi('^\.',$file)
- && ! eregi('^CVS',$file)
- && ! eregi('\.meta$',$file))
- {
- $filearray[$i]=$file;
- $totalsize+=filesize($upload_dir."/".$file);
- $i++;
- }
- }
- closedir($handle);
- }
- else
- {
-// print '
'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'
';
- }
-
-
- print '';
-
- // Ref
- print '| '.$langs->trans('Ref').' | '.$facture->ref.' |
';
-
- // Société
- print '| '.$langs->trans('Company').' | '.$societe->getNomUrl(1).' |
';
-
- print '| '.$langs->trans("NbOfAttachedFiles").' | '.sizeof($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
- print "
\n";
- print "\n";
-
- if ($mesg) { print $mesg."
"; }
-
- // Affiche formulaire upload
- $html=new Form($db);
- $html->form_attach_new_file('document.php?facid='.$facture->id);
+ if ($facture->fetch($facid))
+ {
+ $facref = sanitize_string($facture->ref);
- // Affiche liste des documents existant
- print_titre($langs->trans("AttachedFiles"));
+ $upload_dir = $conf->facture->dir_output.'/'.$facref;
+
+ $societe = new Societe($db);
+ $societe->fetch($facture->socid);
- print '';
- print '';
- print '| '.$langs->trans("Document").' | ';
- print ''.$langs->trans("Size").' | ';
- print ''.$langs->trans("Date").' | ';
- print " |
\n";
-
- if (is_dir($upload_dir))
- {
- $handle=opendir($upload_dir);
- if ($handle)
- {
- $var=true;
- while (($file = readdir($handle))!==false)
+ $head = facture_prepare_head($facture);
+ dolibarr_fiche_head($head, 'documents', $langs->trans('InvoiceCustomer'));
+
+ // Construit liste des fichiers
+ clearstatcache();
+
+ $totalsize=0;
+ $filearray=array();
+
+ $errorlevel=error_reporting();
+ error_reporting(0);
+ $handle=opendir($upload_dir);
+ error_reporting($errorlevel);
+ if ($handle)
{
- if (! is_dir($dir.$file)
- && ! eregi('^\.',$file)
- && ! eregi('^CVS',$file)
- && ! eregi('\.meta$',$file))
- {
- $var=!$var;
- print '';
- print '| ';
- echo ''.$file.'';
- print " | \n";
- print ''.filesize($upload_dir.'/'.$file). ' '.$langs->trans("bytes").' | ';
- print ''.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).' | ';
- print '';
- if ($file == $facref . '.pdf')
+ $i=0;
+ while (($file = readdir($handle))!==false)
{
- echo '-';
+ if (! is_dir($dir.$file)
+ && ! eregi('^\.',$file)
+ && ! eregi('^CVS',$file)
+ && ! eregi('\.meta$',$file))
+ {
+ $filearray[$i]=$file;
+ $totalsize+=filesize($upload_dir."/".$file);
+ $i++;
+ }
}
- else
- {
- echo ''.img_delete($langs->trans('Delete')).'';
- }
- print " |
\n";
- }
+ closedir($handle);
}
- closedir($handle);
- }
- else
- {
- print ''.$langs->trans('ErrorCantOpenDir').' '.$upload_dir.'
';
- }
- }
- print '
';
-
- }
- else
- {
- dolibarr_print_error($db);
- }
+ else
+ {
+ // print ''.$langs->trans("ErrorCanNotReadDir",$upload_dir).'
';
+ }
+
+
+ print '';
+
+ // Ref
+ print '| '.$langs->trans('Ref').' | '.$facture->ref.' |
';
+
+ // Société
+ print '| '.$langs->trans('Company').' | '.$societe->getNomUrl(1).' |
';
+
+ print '| '.$langs->trans("NbOfAttachedFiles").' | '.sizeof($filearray).' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+ print "
\n";
+ print "\n";
+
+ if ($mesg) { print $mesg."
"; }
+
+ // Affiche formulaire upload
+ $html=new Form($db);
+ $html->form_attach_new_file('document.php?facid='.$facture->id);
+
+ // Affiche liste des documents existant
+ print_titre($langs->trans("AttachedFiles"));
+
+ print '';
+ print '';
+ print '| '.$langs->trans("Document").' | ';
+ print ''.$langs->trans("Size").' | ';
+ print ''.$langs->trans("Date").' | ';
+ print " |
\n";
+
+ if (is_dir($upload_dir))
+ {
+ $handle=opendir($upload_dir);
+ if ($handle)
+ {
+ $var=true;
+ while (($file = readdir($handle))!==false)
+ {
+ if (! is_dir($dir.$file)
+ && ! eregi('^\.',$file)
+ && ! eregi('^CVS',$file)
+ && ! eregi('\.meta$',$file))
+ {
+ $var=!$var;
+ print '';
+ print '| ';
+ echo ''.$file.'';
+ print " | \n";
+ print ''.filesize($upload_dir.'/'.$file). ' '.$langs->trans("bytes").' | ';
+ print ''.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).' | ';
+ print '';
+ if ($file == $facref . '.pdf')
+ {
+ echo '-';
+ }
+ else
+ {
+ echo ''.img_delete($langs->trans('Delete')).'';
+ }
+ print " |
\n";
+ }
+ }
+ closedir($handle);
+ }
+ else
+ {
+ print ''.$langs->trans('ErrorCantOpenDir').' '.$upload_dir.'
';
+ }
+ }
+ print '
';
+
+ }
+ else
+ {
+ dolibarr_print_error($db);
+ }
}
else
{
diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php
index 5b2f1805388..37ea9b0cf59 100644
--- a/htdocs/contact.class.php
+++ b/htdocs/contact.class.php
@@ -220,28 +220,16 @@ class Contact
/*
- * \brief Retourne chaine dn dand l'annuaire LDAP
+ * \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs
*/
function _load_ldap_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");
- }
-
+ // Object classes
+ $info["objectclass"]=split(',',$conf->global->LDAP_CONTACT_OBJECT_CLASS);
+
// 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;
@@ -262,7 +250,7 @@ class Contact
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_perso && $conf->global->LDAP_FIELD_PHONE_PERSO) $info[$conf->global->LDAP_FIELD_PHONE_PERSO] = $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 && $conf->global->LDAP_FIELD_DESCRIPTION) $info[$conf->global->LDAP_FIELD_DESCRIPTION] = $this->note;
diff --git a/htdocs/lib/ldap.class.php b/htdocs/lib/ldap.class.php
index 2c0fe3ded33..b84d67b347f 100644
--- a/htdocs/lib/ldap.class.php
+++ b/htdocs/lib/ldap.class.php
@@ -39,7 +39,7 @@ class Ldap
/**
* Tableau des serveurs (IP addresses ou nom d'hôtes)
*/
- var $server;
+ var $server=array();
/**
* Base DN (e.g. "dc=foo,dc=com")
*/
@@ -53,7 +53,7 @@ class Ldap
*/
var $domain;
/**
- * Administrateur Ldap
+ * User administrateur Ldap
* Active Directory ne supporte pas les connexions anonymes
*/
var $searchUser;
@@ -112,7 +112,8 @@ class Ldap
global $conf;
//Server
- $this->server = array($conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_HOST_SLAVE);
+ if ($conf->global->LDAP_SERVER_HOST) $this->server[] = $conf->global->LDAP_SERVER_HOST;
+ if ($conf->global->LDAP_SERVER_HOST_SLAVE) $this->server[] = $conf->global->LDAP_SERVER_HOST_SLAVE;
$this->serverPort = $conf->global->LDAP_SERVER_PORT;
$this->ldapProtocolVersion = $conf->global->LDAP_SERVER_PROTOCOLVERSION;
$this->dn = $conf->global->LDAP_SERVER_DN;
@@ -666,9 +667,17 @@ class Ldap
$fp=fopen($file,"w");
if ($fp)
{
- fputs($fp,"# ldapadd -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapinput.in\n");
- fputs($fp,"# ldapmodify -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapinput.in\n");
- fputs($fp,"# ldapdelete -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapinput.in\n");
+ if (ereg('^ldap',$this->server[0]))
+ {
+ $target="-H ".join(',',$this->server);
+ }
+ else
+ {
+ $target="-h ".join(',',$this->server)." -p ".$this->serverPort;
+ }
+ fputs($fp,"# ldapadd $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n");
+ fputs($fp,"# ldapmodify $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n");
+ fputs($fp,"# ldapdelete $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n");
fputs($fp, "dn: ".$dn."\n");
foreach($info as $key => $value)
{
diff --git a/htdocs/user.class.php b/htdocs/user.class.php
index 6177cb297be..acfe613d25f 100644
--- a/htdocs/user.class.php
+++ b/htdocs/user.class.php
@@ -1283,7 +1283,7 @@ class User
/*
- * \brief Retourne chaine dn dand l'annuaire LDAP
+ * \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs
*/
function _load_ldap_info()
@@ -1292,27 +1292,16 @@ class User
$info=array();
- if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
- {
- $info["objectclass"]=array("top",
- "person",
- "organizationalPerson",
- "user");
- }
- else
- {
- $info["objectclass"]=array("top",
- "person",
- "organizationalPerson",
- "inetOrgPerson");
- }
-
+ // Object classes
+ $info["objectclass"]=split(',',$conf->global->LDAP_USER_OBJECT_CLASS);
+
// 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->login && $conf->global->LDAP_FIELD_LOGIN_SAMBA) $info[$conf->global->LDAP_FIELD_LOGIN_SAMBA] = $this->login;
+ if ($this->pass && $conf->global->LDAP_FIELD_PASSWORD) $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypté
if ($this->poste) $info["title"] = $this->poste;
if ($this->societe_id > 0)
{
diff --git a/htdocs/usergroup.class.php b/htdocs/usergroup.class.php
index 94566a18b28..4319f4adec2 100644
--- a/htdocs/usergroup.class.php
+++ b/htdocs/usergroup.class.php
@@ -479,7 +479,7 @@ class UserGroup
/*
- * \brief Retourne chaine dn dand l'annuaire LDAP
+ * \brief Initialise tableau info (tableau des attributs LDAP)
* \return array Tableau info des attributs
*/
function _load_ldap_info()
@@ -487,21 +487,9 @@ class UserGroup
global $conf,$langs;
$info=array();
- if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
- {
- $info["objectclass"]=array("top",
- "person",
- "organizationalPerson",
- "user");
- }
- else
- {
- $info["objectclass"]=array("top",
- "person",
- "organizationalPerson",
- "inetOrgPerson");
- }
-
+ // Object classes
+ $info["objectclass"]=split(',',$conf->global->LDAP_GROUP_OBJECT_CLASS);
+
// Champs
if ($this->nom && $conf->global->LDAP_FIELD_FULLNAME) $info[$conf->global->LDAP_FIELD_FULLNAME] = $this->nom;
if ($this->nom && $conf->global->LDAP_FIELD_NAME) $info[$conf->global->LDAP_FIELD_NAME] = $this->nom;