Fix: Amlioration gestion erreur LDAP openldap

This commit is contained in:
Laurent Destailleur 2007-02-04 01:15:51 +00:00
parent f1429e0cd5
commit f7387c0d5e
10 changed files with 78 additions and 41 deletions

View File

@ -118,6 +118,8 @@ print '<tr><td>LDAP '.$langs->trans("LDAPMemberDn").'</td><td class="valeur">'.$
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_MEMBERS."</td></tr>\n";
// LDAP Server
print '<tr><td>LDAP '.$langs->trans("Type").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_TYPE."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("Version").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PROTOCOLVERSION."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
@ -154,7 +156,7 @@ if ($result > 0)
{
if (! is_array($records))
{
print '<tr><td colspan="2">'.$langs->trans("ErrorFailedToReadLDAP").'</td></tr>';
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
}
else
{
@ -164,7 +166,7 @@ if ($result > 0)
}
else
{
print '<tr><td colspan="2">'.$langs->trans("LDAPRecordNotFound").'</td></tr>';
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
}
$ldap->unbind();

View File

@ -2259,8 +2259,8 @@ class Facture extends CommonObject
/**
\brief Renvoi liste des factures remplacables
Statut validee + aucun paiement + non paye + pas deja remplacées
\param socid Id societe
Statut validée + aucun paiement + non payée + pas deja remplacée
\param socid Id societe
\return array Tableau des factures ('id'=>id, 'ref'=>ref, 'statut'=>status)
*/
function list_replacable_invoices($socid=0)
@ -2274,9 +2274,10 @@ class Facture extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source";
$sql.= " WHERE f.fk_statut = 1 AND f.paye = 0 AND pf.fk_paiement IS NULL";
$sql.= " AND ff.fk_statut IS NULL"; // Renvoie vrai si pas de jointure
//$sql.= " AND IFNULL(ff.fk_statut,0) = 0"; // Renvoie vrai si pas de jointure ou si jointure vers statut à 0
$sql.= " WHERE f.fk_statut = 1";
$sql.= " AND f.paye = 0"; // Pas classée payée complètement
$sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait
$sql.= " AND ff.fk_statut IS NULL"; // Renvoi vrai si pas facture de remplacement
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
$sql.= " ORDER BY f.facnumber";
@ -2304,7 +2305,7 @@ class Facture extends CommonObject
/**
* \brief Renvoi liste des factures qualifiables pour avoir
* Statut >= validee + pas classé payée completement + pas classé payée partiellement + pas deja remplacée
* Statut >= validée + classée payée completement ou classée payée partiellement + pas deja remplacée
* \param socid Id societe
* \return array Tableau des factures ($id => $ref)
*/
@ -2319,9 +2320,9 @@ class Facture extends CommonObject
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=1)";
$sql.= " WHERE f.fk_statut >= 1";
$sql.= " AND f.paye = 0"; // Pas classé payé complètement
$sql.= " AND f.close_code IS NULL"; // Pas classé payé partiellement
$sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement
$sql.= " AND (f.paye = 1"; // Classée payée complètement
$sql.= " OR f.close_code IS NOT NULL)"; // Classée payée partiellement
$sql.= " AND ff.type IS NULL"; // Renvoi vrai si pas facture de remplacement
if ($socid > 0) $sql.=" AND f.fk_soc = ".$socid;
$sql.= " ORDER BY f.facnumber";

View File

@ -84,7 +84,7 @@ class modAdherent extends DolibarrModules
$this->const[2]= array("ADHERENT_MAIL_EDIT","texte","Voici le rappel des coordonnees que vous avez modifiees (toute information erronee entrainera la non validation de votre inscription) :\r\n\r\n%INFO%\r\n\r\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l'adresse suivante :\r\n%SERVEUR%public/adherents/","Mail d'edition");
$this->const[3] = array("ADHERENT_MAIL_RESIL","texte","Votre adhesion sur %SERVEUR% vient d'etre resilie.\r\nNous esperons vous revoir tres bientot","Mail de résiliation");
$this->const[4] = array("ADHERENT_MAIL_NEW","texte","Merci de votre inscription. Votre adhesion devrait etre rapidement validee.^M\nVoici le rappel des coordonnees que vous avez rentrees (toute information erronee entrainera la non validation de votre inscription) :\r\n\r\n%INFO%\r\n\r\nVous pouvez a tout moment, grace a votre login et mot de passe, modifier vos coordonnees a l'adresse suivante :\r\n%SERVEUR%public/adherents/","Mail de nouvel inscription");
$this->const[5] = array("ADHERENT_MAIL_VALID_SUBJECT","chaine"," Votre adh<E9>sion a ete valid<E9>e sur %SERVEUR%","sujet du mail de validation");
$this->const[5] = array("ADHERENT_MAIL_VALID_SUBJECT","chaine"," Votre adhesion a ete validee sur %SERVEUR%","sujet du mail de validation");
$this->const[6] = array("ADHERENT_MAIL_RESIL_SUBJECT","chaine","Resiliation de votre adhesion sur %SERVEUR% ","sujet du mail de resiliation");
$this->const[7] = array("ADHERENT_MAIL_NEW_SUBJECT","chaine","Bienvenue sur %SERVEUR%","Sujet du mail de nouvelle adhesion");
$this->const[8] = array("ADHERENT_MAIL_EDIT_SUBJECT","chaine","Votre fiche a ete editee sur %SERVEUR%","Sujet du mail d'edition");
@ -101,7 +101,7 @@ class modAdherent extends DolibarrModules
$this->const[19] = array("ADHERENT_SPIP_SERVEUR","chaine","","serveur spip");
$this->const[20] = array("ADHERENT_SPIP_DB","chaine","","db spip");
$this->const[21] = array("ADHERENT_MAIL_FROM","chaine","","From des mails");
$this->const[22] = array("ADHERENT_MAIL_COTIS","texte","Bonjour %PRENOM%,^M\n^M\nCet email confirme que votre cotisation a ete recue\r\net enregistree","Mail de validation de cotisation");
$this->const[22] = array("ADHERENT_MAIL_COTIS","texte","Bonjour %PRENOM%,\r\nCet email confirme que votre cotisation a ete recue\r\net enregistree","Mail de validation de cotisation");
$this->const[23] = array("ADHERENT_MAIL_COTIS_SUBJECT","chaine"," Recu de votre cotisation","sujet du mail de validation de cotisation");
$this->const[24] = array("ADHERENT_TEXT_NEW_ADH","texte","","Texte d'entete du formulaire d'adhesion en ligne");
$this->const[25] = array("ADHERENT_CARD_HEADER_TEXT","chaine","%ANNEE%","Texte imprime sur le haut de la carte adherent");

View File

@ -531,7 +531,7 @@ LDAPServerUseTLSExample=Your LDAP server use TLS
LDAPServerDn=Server DN
LDAPAdminDn=Administrator DN
LDAPAdminDnExample=Complete DN (ex: cn=adminldap,dc=society,dc=com)
LDAPPassword=administrator password
LDAPPassword=Administrator password
LDAPUserDn=Users' DN
LDAPUserDnExample=Complete DN (ex: ou=users,dc=society,dc=com)
LDAPGroupDn=Groups' DN
@ -559,7 +559,7 @@ LDAPTestSynchroGroup=Test group's synchronization
LDAPTestSynchroMember=Test member's synchronization
LDAPSynchroOK=Synchronization test successful
LDAPSynchroKO=Failed synchronization test
LDAPSynchroKOMayBePermissions=Failed synchronization test. Chack that connexion to server is correctly configured and allows LDAP udpates
LDAPSynchroKOMayBePermissions=Failed synchronization test. Check that connexion to server is correctly configured and allows LDAP udpates
LDAPTCPConnectOK=TCP connect to LDAP server successful (Server=%s, Port=%s)
LDAPTCPConnectKO=TCP connect to LDAP server failed (Server=%s, Port=%s)
LDAPBindOK=Connect/Authentificate to LDAP server sucessfull (Server=%s, Port=%s, Admin=%s, Password=%s)

View File

@ -16,7 +16,7 @@ InvoiceReplacementAsk=Replacement invoice for invoice
InvoiceReplacementDesc=<b>Replacement invoice</b> is used to cancel and replace completely an invoice with no paiement already recevided.<br>Reference of canceled invoice is required.
InvoiceAvoir=Credit note
InvoiceAvoirAsk=Credit note to correct invoice
InvoiceAvoirDesc=The <b>credit note</b> is a negative invoice used to solve fact that an invoice has an higher amount that amount that was or will be payed (all possible reasons).
InvoiceAvoirDesc=The <b>credit note</b> is a negative invoice used to solve fact that an invoice has an higher amount that should be (all possible reasons) or a product returned after invoice was payed.
ReplaceInvoice=Replace invoice %s
ReplacedByInvoice=Replaced by invoice %s
CorrectInvoice=Correct invoice %s
@ -85,7 +85,7 @@ BillShortStatusValidated=Validated
BillShortStatusStarted=Started
BillShortStatusNotPayed=Not payed
BillShortStatusClosedUnpayed=Closed
BillShortStatusClosedPayedPartially=Payed (part)
BillShortStatusClosedPayedPartially=Payed (partially)
PaymentStatusToValidShort=To validate
ErrorVATIntraNotConfigured=Intracommunautary VAT number not yet defined
ErrorNoPaiementModeConfigured=No paiment mode yet defined

View File

@ -17,4 +17,4 @@ LDAPGroups=Groups in LDAP database
SynchronizeDolibarr2Ldap=Synchronize user (Dolibarr -> LDAP)
UserSynchronized=User synchronized
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.

View File

@ -16,7 +16,7 @@ InvoiceReplacementAsk=Facture de remplacement de la facture
InvoiceReplacementDesc=La <b>facture de remplacement</b> sert à annuler et remplacer une facture existante sur laquelle aucun paiement n'a encore eu lieu.<br>La référence de la facture qui doit être annulée est obligatoire.
InvoiceAvoir=Facture avoir
InvoiceAvoirAsk=Facture avoir pour correction de la facture
InvoiceAvoirDesc=La <b>facture d'avoir</b> est une facture négative destinée à compenser une facture comportant un montant supérieur à ce qui a été ou sera réellement payé (toutes causes possibles).
InvoiceAvoirDesc=La <b>facture d'avoir</b> est une facture négative destinée à compenser une facture comportant un montant supérieur à ce qui aurait du (toutes causes possibles) ou parce qu'un produit a été retourné après que la facture soit payée.
ReplaceInvoice=Remplace la facture %s
ReplacedByInvoice=Remplacée par la facture %s
CorrectInvoice=Corrige facture %s

View File

@ -213,8 +213,18 @@ class Ldap
if ($this->serverType == "activedirectory")
{
$this->setReferrals();
$connected=2;
$result=$this->setReferrals();
if ($result)
{
//$this->bind=???? Comment positionne-t-on bind avec activedirectory ?
//si bind non défini, les autres fonctions échouent
$connected=2;
break;
}
else
{
$this->error=ldap_errno($this->connection).' '.ldap_error($this->connection);
}
}
else
{
@ -656,6 +666,9 @@ 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");
fputs($fp, "dn: ".$dn."\n");
foreach($info as $key => $value)
{
@ -817,11 +830,19 @@ class Ldap
return -1;
}
$entry = ldap_first_entry($this->connection, $ldapSearchResult);
$ldapBinary = ldap_get_values_len ($this->connection, $entry, "objectsid");
$SIDText = $this->binSIDtoText($ldapBinary[0]);
return $SIDText;
return $ldapBinary;
$entry = ldap_first_entry($this->connection, $ldapSearchResult);
if ($entry)
{
$ldapBinary = ldap_get_values_len ($this->connection, $entry, "objectsid");
$SIDText = $this->binSIDtoText($ldapBinary[0]);
return $SIDText;
//return $ldapBinary;
}
else
{
return '?';
}
}
/**

View File

@ -729,7 +729,14 @@ else
// Ref
print '<tr><td width="25%" valign="top">'.$langs->trans("Ref").'</td>';
print '<td width="50%">'.$fuser->id.'</td>';
print '<td width="50%">';
if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
print $fuser->id;
if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>';
print '</td>';
print '<td align="center" valign="middle" width="25%" rowspan="'.$rowspan.'">';
if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))
{

View File

@ -61,14 +61,13 @@ if ($_GET["action"] == 'dolibarr2ldap')
$db->begin();
$ldap=new Ldap();
$ldap->connect_bind();
$result=$ldap->connect_bind();
$info=$fuser->_load_ldap_info();
$dn=$fuser->_load_ldap_dn($info);
$ret=$ldap->update($dn,$info,$user); // Marche en creation LDAP et mise a jour
$result=$ldap->update($dn,$info,$user); // Marche en creation LDAP et mise a jour
if ($ret >= 0)
if ($result >= 0)
{
$message.='<div class="ok">'.$langs->trans("UserSynchronized").'</div>';
$db->commit();
@ -153,6 +152,8 @@ print '<tr><td>LDAP '.$langs->trans("LDAPUserDn").'</td><td class="valeur">'.$co
print '<tr><td>LDAP '.$langs->trans("LDAPNamingAttribute").'</td><td class="valeur">'.$conf->global->LDAP_KEY_USERS."</td></tr>\n";
// LDAP Server
print '<tr><td>LDAP '.$langs->trans("Type").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_TYPE."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("Version").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PROTOCOLVERSION."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPPrimaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPSecondaryServer").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_HOST_SLAVE."</td></tr>\n";
print '<tr><td>LDAP '.$langs->trans("LDAPServerPort").'</td><td class="valeur">'.$conf->global->LDAP_SERVER_PORT."</td></tr>\n";
@ -199,21 +200,26 @@ if ($result > 0)
$info=$fuser->_load_ldap_info();
$dn=$fuser->_load_ldap_dn($info,1);
$search = "(".$fuser->_load_ldap_dn($info,2).")";
$result=$ldap->search($dn,$search);
if ($result < 0)
{
dolibarr_print_error($db,$ldap->error);
}
$records=$ldap->search($dn,$search);
//print_r($records);
// Affichage arbre
if (sizeof($result))
if (sizeof($records) && (! isset($records['count']) || $records['count'] > 0))
{
$html=new Form($db);
$html->show_ldap_content($result,0,0,true);
if (! is_array($records))
{
print '<tr '.$bc[false].'><td colspan="2"><font class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</font></td></tr>';
}
else
{
$html=new Form($db);
$result=$html->show_ldap_content($records,0,0,true);
}
}
else
{
print '<tr><td colspan="2">'.$langs->trans("LDAPRecordNotFound").'</td></tr>';
print '<tr '.$bc[false].'><td colspan="2">'.$langs->trans("LDAPRecordNotFound").' (dn='.$dn.' - search='.$search.')</td></tr>';
}
$ldap->unbind();