Amélioration gestion erreur synchro LDAP

This commit is contained in:
Laurent Destailleur 2006-11-18 21:59:10 +00:00
parent 75a82a31ce
commit e69b80ac52
17 changed files with 728 additions and 534 deletions

View File

@ -0,0 +1,13 @@
# ldapadd_sample1.txt
#
# Use this sample to add a dc "my-domain".
# This is the first thing to create
#
# ldapadd -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapadd_sample1.txt
dn: dc=my-domain,dc=com
objectclass: dcObject
objectClass: organization
objectClass: top
dc: my-domain
o: Mon organisation

View File

@ -0,0 +1,10 @@
# ldapadd_sample2.txt
#
# Use this sample to add a ou "contacts"
# This is the second thing to create after creating the root my-domain
#
# ldapadd -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapadd_sample1.txt
dn: ou=contacts,dc=my-domain,dc=com
objectClass: organizationalUnit
ou: contacts

View File

@ -0,0 +1,19 @@
# ldapadd_sample3.txt
#
# Use this sample to add cn records
# This is the step to create records inside tree ou=contacts,dc=my-domain,dc=com
#
# ldapadd -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapadd_sample3.txt
dn: cn=Bruno et Sabine Tary,ou=contacts,dc=my-domain,dc=com
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
objectClass: top
cn: Bruno et Sabine Tary
cn: Barbara Jensen
cn: Babs Jensen
sn: Jensen
description: aaa
title: this is title
mail: mail@mail.com

View File

@ -0,0 +1,9 @@
# ldapdelete_sample1.txt
#
# Use this sample to delete a dc "my-domain"
# This delete the first level of LDAP tree.
#
# ldapmodify -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapdelete_sample1.txt
dn: dc=my-domain,dc=com
changetype: delete

View File

@ -0,0 +1,9 @@
# ldapdelete_sample3.txt
#
# Use this sample to delete cn records
# This is the step to delete a cn record stored inside tree ou=contacts,dc=my-domain,dc=com
#
# ldapmodify -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapdelete_sample3.txt
dn: cn=Bruno et Sabine Tary,ou=contacts,dc=my-domain,dc=com
changetype: delete

View File

@ -0,0 +1,14 @@
# ldapmodify_sample1.txt
#
# Use this sample to modify a dc "my-domain"
#
# ldapmodify -c -v -D cn=Manager,dc=my-domain,dc=com -W -f ldapmodify_sample1.txt
dn: dc=my-domain,dc=com
changetype: modify
replace: o
objectclass: dcObject
objectClass: organization
objectClass: top
dc: my-domain
o: Mon organisation

View File

@ -54,49 +54,23 @@ if (!$user->admin)
if ($_GET["action"] == 'setvalue' && $user->admin) if ($_GET["action"] == 'setvalue' && $user->admin)
{ {
if (! dolibarr_set_const($db, 'LDAP_SERVER_TYPE',$_POST["type"])) $error=0;
if (! dolibarr_set_const($db, 'LDAP_SERVER_TYPE',$_POST["type"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION',$_POST["version"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST',$_POST["host"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE',$_POST["slave"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_SERVER_PORT',$_POST["port"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_SERVER_DN',$_POST["dn"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_ADMIN_DN',$_POST["admin"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_ADMIN_PASS',$_POST["pass"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS',$_POST["usetls"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE',$_POST["activecontact"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE',$_POST["activesynchro"])) $error++;
if ($error)
{ {
print $db->error(); dolibarr_print_error($db->error());
}
if (! dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION',$_POST["version"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST',$_POST["host"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE',$_POST["slave"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_SERVER_PORT',$_POST["port"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_SERVER_DN',$_POST["dn"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_ADMIN_DN',$_POST["admin"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_ADMIN_PASS',$_POST["pass"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS',$_POST["usetls"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE',$_POST["activecontact"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE',$_POST["activesynchro"]))
{
print $db->error();
} }
} }

View File

@ -54,9 +54,18 @@ if (!$user->admin)
if ($_GET["action"] == 'setvalue' && $user->admin) if ($_GET["action"] == 'setvalue' && $user->admin)
{ {
if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN',$_POST["contactdn"])) $error=0;
if (! dolibarr_set_const($db, 'LDAP_CONTACT_DN',$_POST["contactdn"])) $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++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',$_POST["fieldphone"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',$_POST["fieldfax"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',$_POST["fieldmobile"])) $error++;
if ($error)
{ {
print $db->error(); dolibarr_print_error($db->error());
} }
} }
@ -111,6 +120,8 @@ if ($conf->global->LDAP_MEMBERS_ACTIVE)
dolibarr_fiche_head($head, $hselected, $langs->trans("LDAP")); dolibarr_fiche_head($head, $hselected, $langs->trans("LDAP"));
print $langs->trans("LDAPDescContact").'<br>';
print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
@ -130,6 +141,43 @@ print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPContactDn").'</td><td>';
print '<input size="38" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.'">'; print '<input size="38" type="text" name="contactdn" value="'.$conf->global->LDAP_CONTACT_DN.'">';
print '</td><td>'.$langs->trans("LDAPContactDnExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPContactDnExample").'</td></tr>';
// Name
$var=!$var;
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>';
// 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>';
// 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>';
// 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>';
// 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 '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>'; print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>'; print '</table>';
@ -138,6 +186,7 @@ print '</form>';
print '</div>'; print '</div>';
print info_admin($langs->trans("LDAPDescValues"));
$db->close(); $db->close();

View File

@ -54,21 +54,21 @@ if (!$user->admin)
if ($_GET["action"] == 'setvalue' && $user->admin) if ($_GET["action"] == 'setvalue' && $user->admin)
{ {
if (! dolibarr_set_const($db, 'LDAP_USER_DN',$_POST["user"])) $error=0;
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_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++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME',$_POST["fieldfirstname"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MAIL',$_POST["fieldmail"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_PHONE',$_POST["fieldphone"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_FAX',$_POST["fieldfax"])) $error++;
if (! dolibarr_set_const($db, 'LDAP_FIELD_MOBILE',$_POST["fieldmobile"])) $error++;
if ($error)
{ {
print $db->error(); dolibarr_print_error($db->error());
}
if (! dolibarr_set_const($db, 'LDAP_GROUP_DN',$_POST["group"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_FIELD_LOGIN',$_POST["fieldlogin"]))
{
print $db->error();
}
if (! dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION',$_POST["filterconnection"]))
{
print $db->error();
} }
} }
@ -123,6 +123,9 @@ if ($conf->global->LDAP_MEMBERS_ACTIVE)
dolibarr_fiche_head($head, $hselected, $langs->trans("LDAP")); dolibarr_fiche_head($head, $hselected, $langs->trans("LDAP"));
print $langs->trans("LDAPDescUsers").'<br>';
print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?action=setvalue">';
@ -151,122 +154,58 @@ print '</td><td>'.$langs->trans("LDAPGroupDnExample").'</td></tr>';
// Filtre de connexion // Filtre de connexion
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFilterConnection").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFilterConnection").'</td><td>';
if ($conf->global->LDAP_FILTER_CONNECTION)
{
print '<input size="38" type="text" name="filterconnection" value="'.$conf->global->LDAP_FILTER_CONNECTION.'">'; print '<input size="38" type="text" name="filterconnection" value="'.$conf->global->LDAP_FILTER_CONNECTION.'">';
}
else
{
print '<input size="38" type="text" name="filterconnection" value="&(objectClass=user)(objectCategory=person)">';
}
print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPFilterConnectionExample").'</td></tr>';
// Login unix // Login unix
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginUnix").'</td><td>';
if ($conf->global->LDAP_FIELD_LOGIN)
{
print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_FIELD_LOGIN.'">'; print '<input size="25" type="text" name="fieldlogin" value="'.$conf->global->LDAP_FIELD_LOGIN.'">';
}
else
{
print '<input size="25" type="text" name="fieldlogin" value="uid">';
}
print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPFieldLoginExample").'</td></tr>';
// Login samba // Login samba
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldLoginSamba").'</td><td>';
if ($conf->global->LDAP_FIELD_LOGIN_SAMBA)
{
print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_FIELD_LOGIN_SAMBA.'">'; print '<input size="25" type="text" name="fieldloginsamba" value="'.$conf->global->LDAP_FIELD_LOGIN_SAMBA.'">';
}
else
{
print '<input size="25" type="text" name="fieldloginsamba" value="samaccountname">';
}
print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPFieldLoginSambaExample").'</td></tr>';
// Name // Name
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldName").'</td><td>';
if ($conf->global->LDAP_FIELD_NAME)
{
print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_FIELD_NAME.'">'; print '<input size="25" type="text" name="fieldname" value="'.$conf->global->LDAP_FIELD_NAME.'">';
}
else
{
print '<input size="25" type="text" name="fieldname" value="sn">';
}
print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPFieldNameExample").'</td></tr>';
// Firstname // Firstname
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFirstName").'</td><td>';
if ($conf->global->LDAP_FIELD_FIRSTNAME)
{
print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'">'; print '<input size="25" type="text" name="fieldfirstname" value="'.$conf->global->LDAP_FIELD_FIRSTNAME.'">';
}
else
{
print '<input size="25" type="text" name="fieldfirstname" value="givenname">';
}
print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPFieldFirstNameExample").'</td></tr>';
// Mail // Mail
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMail").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMail").'</td><td>';
if ($conf->global->LDAP_FIELD_MAIL)
{
print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_FIELD_MAIL.'">'; print '<input size="25" type="text" name="fieldmail" value="'.$conf->global->LDAP_FIELD_MAIL.'">';
}
else
{
print '<input size="25" type="text" name="fieldmail" value="mail">';
}
print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPFieldMailExample").'</td></tr>';
// Phone // Phone
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldPhone").'</td><td>';
if ($conf->global->LDAP_FIELD_PHONE)
{
print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">'; print '<input size="25" type="text" name="fieldphone" value="'.$conf->global->LDAP_FIELD_PHONE.'">';
}
else
{
print '<input size="25" type="text" name="fieldphone" value="telephonenumber">';
}
print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPFieldPhoneExample").'</td></tr>';
// Fax // Fax
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldFax").'</td><td>';
if ($conf->global->LDAP_FIELD_FAX)
{
print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">'; print '<input size="25" type="text" name="fieldfax" value="'.$conf->global->LDAP_FIELD_FAX.'">';
}
else
{
print '<input size="25" type="text" name="fieldfax" value="facsimiletelephonenumber">';
}
print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPFieldFaxExample").'</td></tr>';
// Mobile // Mobile
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>'; print '<tr '.$bc[$var].'><td>'.$langs->trans("LDAPFieldMobile").'</td><td>';
if ($conf->global->LDAP_FIELD_MOBILE)
{
print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">'; print '<input size="25" type="text" name="fieldmobile" value="'.$conf->global->LDAP_FIELD_MOBILE.'">';
}
else
{
print '<input size="25" type="text" name="fieldmobile" value="mobile">';
}
print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPFieldMobileExample").'</td></tr>';
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>'; print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td></tr>';
print '</table>'; print '</table>';
@ -274,6 +213,7 @@ print '</form>';
print '</div>'; print '</div>';
print info_admin($langs->trans("LDAPDescValues"));
$db->close(); $db->close();

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -178,31 +178,47 @@ class Contact
} }
/** /**
* \brief Mise à jour de l'arbre ldap * \brief Mise à jour de l'arbre LDAP
* \param user Utilisateur qui effectue la mise à jour * \param user Utilisateur qui effectue la mise à jour
* * \return int <0 si ko, >0 si ok
*/ */
function update_ldap($user) function update_ldap($user)
{ {
global $conf, $langs;
$info = array(); $info = array();
dolibarr_syslog("Contact::update_ldap",LOG_DEBUG);
dolibarr_syslog("Contact.class::update_ldap",LOG_DEBUG);
$this->fetch($this->id); $this->fetch($this->id);
$ldap = New AuthLdap();
if ($ldap->connect()) $ldap=new AuthLdap();
$result=$ldap->connect();
if ($result)
{ {
if (bind()) $bind='';
if ($conf->global->LDAP_ADMIN_DN && $conf->global->LDAP_ADMIN_PASS)
{ {
if (LDAP_SERVER_TYPE == 'activedirectory') //enlever utf8 pour etre compatible Windows dolibarr_syslog("Contact.class::update_ldap authBind user=".$conf->global->LDAP_ADMIN_DN,LOG_DEBUG);
$bind=$ldap->authBind($conf->global->LDAP_ADMIN_DN,$conf->global->LDAP_ADMIN_PASS);
}
else
{ {
dolibarr_syslog("Contact.class::update_ldap bind",LOG_DEBUG);
$bind=$ldap->bind();
}
if ($bind)
{
if ($conf->global->LDAP_SERVER_TYPE == 'activedirectory')
{
// Pas de conversion utf8 pour etre compatible Windows
$info["objectclass"][0] = "top"; $info["objectclass"][0] = "top";
$info["objectclass"][1] = "person"; $info["objectclass"][1] = "person";
$info["objectclass"][2] = "organizationalPerson"; $info["objectclass"][2] = "organizationalPerson";
//$info["objectclass"][3] = "inetOrgPerson"; //$info["objectclass"][3] = "inetOrgPerson";
$info["objectclass"][3] = "user"; $info["objectclass"][3] = "user";
$info["cn"] = $this->firstname." ".$this->name; $info["cn"] = trim($this->firstname." ".$this->name);
$info["sn"] = $this->name; $info["sn"] = $this->name;
$info["givenName"] = $this->firstname; $info["givenName"] = $this->firstname;
@ -217,7 +233,7 @@ class Contact
if ($soc->client == 1) if ($soc->client == 1)
{ {
$info["businessCategory"] = "Clients"; $info["businessCategory"] = "Customers";
} }
elseif ($soc->client == 2) elseif ($soc->client == 2)
{ {
@ -226,7 +242,7 @@ class Contact
if ($soc->fournisseur == 1) if ($soc->fournisseur == 1)
{ {
$info["businessCategory"] = "Fournisseurs"; $info["businessCategory"] = "Suppliers";
} }
if ($soc->ville) if ($soc->ville)
@ -257,80 +273,83 @@ class Contact
$info["facsimileTelephoneNumber"] = dolibarr_print_phone($this->fax); $info["facsimileTelephoneNumber"] = dolibarr_print_phone($this->fax);
if ($this->note) if ($this->note)
$info["description"] = ($this->note); $info["description"] = $this->note;
if ($this->email) if ($this->email)
$info["mail"] = $this->email; $info["mail"] = $this->email;
$dn = "cn=".$info["cn"].",".LDAP_CONTACT_DN; $dn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
$r = @ldap_delete($ds, $dn); // On supprime et on insère
dolibarr_syslog("Contact.class::update_ldap dn=".$dn." info=".$info);
if (! @ldap_add($ds, $dn, $info)) $r = @ldap_delete($ldap->connection, $dn);
if (! @ldap_add($ldap->connection, $dn, $info))
{ {
$this->error[0] = ldap_err2str(ldap_errno($ds)); $this->error = ldap_err2str(ldap_errno($ldap->connection));
dolibarr_syslog("Contact.class::update_ldap ldap_add ".$this->error);
return -1;
}
else
{
dolibarr_syslog("Contact.class::update_ldap rowid=".$this->rowid." added in LDAP");
} }
} }
else else
{ {
$info["objectclass"][0] = "top"; // OpenLDAP. On encode les param en utf8
$info["objectclass"][1] = "person";
$info["objectclass"][2] = "organizationalPerson";
$info["objectclass"][3] = "inetOrgPerson";
$info["cn"] = utf8_encode($this->firstname." ".$this->name); $info["objectclass"]=array("top",
$info["sn"] = utf8_encode($this->name); "person",
$info["givenName"] = utf8_encode($this->firstname); "organizationalPerson",
"inetOrgPerson");
if ($this->poste) // Champs obligatoires
$info["title"] = utf8_encode($this->poste); $info["cn"] = utf8_encode(trim($this->firstname." ".$this->name));
if ($this->name) $info[$conf->global->LDAP_FIELD_NAME] = utf8_encode($this->name);
else
{
$langs->load("other");
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Name"));
return -1;
}
// Champs optionnels
if ($this->firstname) $info[$conf->global->LDAP_FIELD_FIRSTNAME] = utf8_encode($this->firstname);
if ($this->poste) $info["title"] = utf8_encode($this->poste);
if ($this->socid > 0) if ($this->socid > 0)
{ {
$soc = new Societe($this->db); $soc = new Societe($this->db);
$soc->fetch($this->socid); $soc->fetch($this->socid);
$info["o"] = utf8_encode($soc->nom); $info["o"] = utf8_encode($soc->nom);
if ($soc->client == 1) if ($soc->client == 1) $info["businessCategory"] = utf8_encode("Customers");
$info["businessCategory"] = utf8_encode("Clients"); if ($soc->client == 2) $info["businessCategory"] = utf8_encode("Prospects");
elseif ($soc->client == 2) if ($soc->fournisseur == 1) $info["businessCategory"] = utf8_encode("Suppliers");
$info["businessCategory"] = utf8_encode("Prospects"); if ($soc->adresse) $info["street"] = utf8_encode($soc->adresse);
if ($soc->cp) $info["postalCode"] = utf8_encode($soc->cp);
if ($soc->fournisseur == 1) if ($soc->ville) $info["l"] = utf8_encode($soc->ville);
$info["businessCategory"] = utf8_encode("Fournisseurs");
if ($soc->ville)
{
if ($soc->adresse)
$info["street"] = utf8_encode($soc->adresse);
if ($soc->cp)
$info["postalCode"] = utf8_encode($soc->cp);
$info["l"] = utf8_encode($soc->ville);
}
} }
if ($this->phone_pro) if ($this->phone_pro) $info[$conf->global->LDAP_FIELD_PHONE] = utf8_encode($this->phone_pro);
$info["telephoneNumber"] = dolibarr_print_phone($this->phone_pro);
if ($this->phone_perso) if ($this->phone_perso) $info["homePhone"] = utf8_encode($this->phone_perso);
$info["homePhone"] = dolibarr_print_phone($this->phone_perso);
if ($this->phone_mobile) if ($this->phone_mobile) $info[$conf->global->LDAP_FIELD_MOBILE] = utf8_encode($this->phone_mobile);
$info["mobile"] = dolibarr_print_phone($this->phone_mobile);
if ($this->fax) if ($this->fax) $info[$conf->global->LDAP_FIELD_FAX] = utf8_encode($this->fax);
$info["facsimileTelephoneNumber"] = dolibarr_print_phone($this->fax);
if ($this->note) if ($this->note) $info["description"] = utf8_encode($this->note);
$info["description"] = ($this->note);
if(LDAP_SERVER_TYPE == 'egroupware') if ($this->email) $info[$conf->global->LDAP_FIELD_MAIL] = utf8_encode($this->email);
if ($conf->global->LDAP_SERVER_TYPE == 'egroupware')
{ {
$info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware $info["objectclass"][4] = "phpgwContact"; // compatibilite egroupware
if ($this->email) if ($this->email) $info["rfc822Mailbox"] = $this->email;
$info["rfc822Mailbox"] = $this->email;
$info['uidnumber'] = $this->id; $info['uidnumber'] = $this->id;
@ -338,7 +357,6 @@ class Contact
$info['phpgwMailType'] = 'INTERNET'; $info['phpgwMailType'] = 'INTERNET';
$info['phpgwMailHomeType'] = 'INTERNET'; $info['phpgwMailHomeType'] = 'INTERNET';
$info["uid"] = $this->id. ":".$info["sn"];
$info["phpgwContactTypeId"] = 'n'; $info["phpgwContactTypeId"] = 'n';
$info["phpgwContactCatId"] = 0; $info["phpgwContactCatId"] = 0;
$info["phpgwContactAccess"] = "public"; $info["phpgwContactAccess"] = "public";
@ -353,37 +371,44 @@ class Contact
if ($this->phone_mobile) if ($this->phone_mobile)
$info["phpgwCellTelephoneNumber"] = dolibarr_print_phone($this->phone_mobile); $info["phpgwCellTelephoneNumber"] = dolibarr_print_phone($this->phone_mobile);
} }
else
$info["uid"] = "Dolibarr ".$this->id. ": ".utf8_encode(trim($this->firstname." ".$this->name));
$dn = "cn=".$info["cn"].",".$conf->global->LDAP_CONTACT_DN;
// On supprime et on insère
dolibarr_syslog("Contact.class::update_ldap dn=".$dn." info=".$info);
$result = $ldap->delete($dn);
$result = $ldap->add($dn, $info);
if ($result <= 0)
{ {
if ($this->email) $this->error = $ldap->error." ".ldap_errno($ldap->connection)." ".ldap_error($ldap->connection);
$info["mail"] = $this->email; dolibarr_syslog("Contact.class::update_ldap ".$this->error);
} print_r($info);
return -1;
$dn = "cn=".$info["cn"].",".LDAP_CONTACT_DN;
dolibarr_syslog("Contact::update_ldap dn : ".$dn,LOG_DEBUG);
$r = @ldap_delete($ds, $dn);
if (! @ldap_add($ds, $dn, $info))
{
$this->error[0] = ldap_err2str(ldap_errno($ds));
dolibarr_syslog("Contact::update_ldap error : ".$this->error[0],LOG_ERR);
}
}
} }
else else
{ {
dolibarr_syslog("Contact::update_ldap bind failed",LOG_DEBUG); dolibarr_syslog("Contact.class::update_ldap rowid=".$this->rowid." added in LDAP");
}
} }
$ldap->unbind(); $ldap->unbind();
return 1;
} }
else else
{ {
$this->error = "Error ".ldap_errno($ldap->connection)." ".ldap_error($ldap->connection);
dolibarr_syslog("Contact.class::update_ldap bind failed",LOG_DEBUG);
return -1;
}
}
else
{
$this->error="Failed to connect to LDAP server !";
dolibarr_syslog("Contact::update_ldap Connexion failed",LOG_DEBUG); dolibarr_syslog("Contact::update_ldap Connexion failed",LOG_DEBUG);
echo "Impossible de se connecter au serveur LDAP !"; return -1;
} }
} }
@ -484,12 +509,12 @@ class Contact
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->poste = $obj->poste; $this->poste = $obj->poste;
$this->fullname = $this->firstname . ' ' . $this->name; $this->fullname = trim($this->firstname . ' ' . $this->name);
$this->phone_pro = $obj->phone; $this->phone_pro = trim($obj->phone);
$this->fax = $obj->fax; $this->fax = trim($obj->fax);
$this->phone_perso = $obj->phone_perso; $this->phone_perso = trim($obj->phone_perso);
$this->phone_mobile = $obj->phone_mobile; $this->phone_mobile = trim($obj->phone_mobile);
$this->code = $obj->code; $this->code = $obj->code;
$this->email = $obj->email; $this->email = $obj->email;
@ -615,6 +640,8 @@ class Contact
*/ */
function delete($id) function delete($id)
{ {
global $conf, $langs;
$sql = "SELECT c.name, c.firstname FROM ".MAIN_DB_PREFIX."socpeople as c"; $sql = "SELECT c.name, c.firstname FROM ".MAIN_DB_PREFIX."socpeople as c";
$sql .= " WHERE c.idp = ". $id; $sql .= " WHERE c.idp = ". $id;
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -639,7 +666,7 @@ class Contact
print $this->db->error() . '<br>' . $sql; print $this->db->error() . '<br>' . $sql;
} }
if (defined('MAIN_MODULE_LDAP') && MAIN_MODULE_LDAP) if ($conf->ldap->enabled)
{ {
if (defined('LDAP_CONTACT_ACTIVE') && LDAP_CONTACT_ACTIVE == 1) if (defined('LDAP_CONTACT_ACTIVE') && LDAP_CONTACT_ACTIVE == 1)
{ {
@ -659,8 +686,8 @@ class Contact
$userdn = utf8_encode($this->old_firstname." ".$this->old_name); $userdn = utf8_encode($this->old_firstname." ".$this->old_name);
} }
$dn = "cn=".$userdn.",".LDAP_CONTACT_DN; $dn = "cn=".$userdn.",".$conf->global->LDAP_CONTACT_DN;
$r = @ldap_delete($ds, $dn); $r = @ldap_delete($ldap->connection, $dn);
} }
else else
{ {

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -68,6 +68,62 @@ class modLdap extends DolibarrModules
// Constantes // Constantes
$this->const = array(); $this->const = array();
$r=0;
$this->const[$r][0] = "LDAP_USER_DN";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "ou=users,dc=my-domain,dc=com";
$r++;
$this->const[$r][0] = "LDAP_GROUP_DN";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "ou=groups,dc=my-domain,dc=com";
$r++;
$this->const[$r][0] = "LDAP_FILTER_CONNECTION";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "&(objectClass=user)(objectCategory=person)";
$r++;
$this->const[$r][0] = "LDAP_FIELD_LOGIN";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "uid";
$r++;
$this->const[$r][0] = "LDAP_FIELD_LOGIN_SAMBA";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "samaccountname";
$r++;
$this->const[$r][0] = "LDAP_FIELD_NAME";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "sn";
$r++;
$this->const[$r][0] = "LDAP_FIELD_FIRSTNAME";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "givenname";
$r++;
$this->const[$r][0] = "LDAP_FIELD_MAIL";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "mail";
$r++;
$this->const[$r][0] = "LDAP_FIELD_PHONE";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "telephonenumber";
$r++;
$this->const[$r][0] = "LDAP_FIELD_FAX";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "facsimiletelephonenumber";
$r++;
$this->const[$r][0] = "LDAP_FIELD_MOBILE";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "mobile";
$r++;
// Boites // Boites
$this->boxes = array(); $this->boxes = array();

View File

@ -538,27 +538,30 @@ LDAPConnectToDNFailed=Connection au DN (%s)
LDAPSetupForVersion3=LDAP server configured for version 3 LDAPSetupForVersion3=LDAP server configured for version 3
LDAPSetupForVersion2=LDAP server configured for version 2 LDAPSetupForVersion2=LDAP server configured for version 2
LDAPFieldLoginUnix=Login (unix) LDAPFieldLoginUnix=Login (unix)
LDAPFieldLoginExample=Default attribute : uid LDAPFieldLoginExample=Suggested value : uid
LDAPFilterConnection=Search filter LDAPFilterConnection=Search filter
LDAPFilterConnectionExample=Default filter : &(objectClass=user)(objectCategory=person) LDAPFilterConnectionExample=Suggested value : &(objectClass=user)(objectCategory=person)
LDAPAttributes=LDAP attributes LDAPAttributes=LDAP attributes
LDAPFieldLoginSamba=Login (samba, activedirectory) LDAPFieldLoginSamba=Login (samba, activedirectory)
LDAPFieldLoginSambaExample=Default attribute : samaccountname (Samba and ActiveDirectory) LDAPFieldLoginSambaExample=Suggested value : samaccountname (Samba and ActiveDirectory)
LDAPFieldName=Name LDAPFieldName=Name
LDAPFieldNameExample=Default attribute : sn LDAPFieldNameExample=Suggested value : sn
LDAPFieldFirstName=Firstname LDAPFieldFirstName=Firstname
LDAPFieldFirstNameExample=Default attribute : givenname LDAPFieldFirstNameExample=Suggested value : givenname
LDAPFieldMail=E-Mail address LDAPFieldMail=E-Mail address
LDAPFieldMailExample=Default attribute : mail LDAPFieldMailExample=Suggested value : mail
LDAPFieldPhone=Phone number LDAPFieldPhone=Phone number
LDAPFieldPhoneExample=Default attribute : telephonenumber LDAPFieldPhoneExample=Suggested value : telephonenumber
LDAPFieldFax=Fax number LDAPFieldFax=Fax number
LDAPFieldFaxExample=Default attribute : facsimiletelephonenumber LDAPFieldFaxExample=Suggested value : facsimiletelephonenumber
LDAPFieldMobile=Cellular phone LDAPFieldMobile=Cellular phone
LDAPFieldMobileExample=Default attribute : mobile LDAPFieldMobileExample=Suggested value : mobile
LDAPParametersAreStillHardCoded=LDAP parametres are still hardcoded (in contact class) LDAPParametersAreStillHardCoded=LDAP parametres are still hardcoded (in contact class)
LDAPSetupNotComplete=LDAP setup not complete (go on others tabs) 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. 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.
##### Products ##### ##### Products #####
ProductSetup=Products module setup ProductSetup=Products module setup
NumberOfProductShowInSelect=Max number of products in combos select lists (0=no limit) NumberOfProductShowInSelect=Max number of products in combos select lists (0=no limit)

View File

@ -510,14 +510,14 @@ LDAPServerUseTLS=Utiliser TLS
LDAPServerUseTLSExample=Votre serveur utilise le TLS LDAPServerUseTLSExample=Votre serveur utilise le TLS
LDAPServerDn=DN du serveur LDAPServerDn=DN du serveur
LDAPAdminDn=DN de l'administrateur LDAPAdminDn=DN de l'administrateur
LDAPAdminDnExample=DN complet (ex: cn=adminldap,dc=societe,dc=com) LDAPAdminDnExample=DN complet (ex: cn=adminldap,dc=my-domain,dc=com)
LDAPPassword=Mot de passe de l'administrateur LDAPPassword=Mot de passe de l'administrateur
LDAPUserDn=DN des utilisateurs LDAPUserDn=DN des utilisateurs
LDAPUserDnExample=DN complet (ex: ou=users,dc=societe,dc=com) LDAPUserDnExample=DN complet (ex: ou=users,dc=my-domain,dc=com)
LDAPGroupDn=DN des groupes LDAPGroupDn=DN des groupes
LDAPGroupDnExample=DN complet (ex: ou=groups,dc=societe,dc=com) LDAPGroupDnExample=DN complet (ex: ou=groups,dc=my-domain,dc=com)
LDAPServerExample=Adresse du serveur (ex: localhost, 192.168.0.2, ldaps://ldap.example.com/) LDAPServerExample=Adresse du serveur (ex: localhost, 192.168.0.2, ldaps://ldap.example.com/)
LDAPServerDnExample=DN complet (ex: dc=societe,dc=com) LDAPServerDnExample=DN complet (ex: dc=my-domain,dc=com)
LDAPPasswordExample=Mot de passe de l'administrateur LDAPPasswordExample=Mot de passe de l'administrateur
LDAPDnSynchroActive=Synchronisation des utilisateurs et groupes LDAPDnSynchroActive=Synchronisation des utilisateurs et groupes
LDAPDnSynchroActiveExample=Synchronisation de LDAP vers Dolibarr ou Dolibarr vers LDAP LDAPDnSynchroActiveExample=Synchronisation de LDAP vers Dolibarr ou Dolibarr vers LDAP
@ -525,7 +525,7 @@ LDAPDnContactActive=Synchronisation des contacts
LDAPDnContactActiveYes=Synchronisation activée LDAPDnContactActiveYes=Synchronisation activée
LDAPDnContactActiveExample=Synchronisation activée/désactivée LDAPDnContactActiveExample=Synchronisation activée/désactivée
LDAPContactDn=DN des contacts Dolibarr LDAPContactDn=DN des contacts Dolibarr
LDAPContactDnExample=DN complet (ex: ou=contacts,dc=societe,dc=com) LDAPContactDnExample=DN complet (ex: ou=contacts,dc=my-domain,dc=com)
LDAPTestConnect=Tester la connexion LDAP LDAPTestConnect=Tester la connexion LDAP
LDAPTCPConnectOK=Connexion TCP au serveur LDAP réussie (Serveur=%s, Port=%s) LDAPTCPConnectOK=Connexion TCP au serveur LDAP réussie (Serveur=%s, Port=%s)
LDAPTCPConnectKO=Connexion TCP au serveur LDAP échouée (Serveur=%s, Port=%s) LDAPTCPConnectKO=Connexion TCP au serveur LDAP échouée (Serveur=%s, Port=%s)
@ -538,27 +538,30 @@ LDAPConnectToDNFailed=Connection au DN (%s)
LDAPSetupForVersion3=Serveur LDAP configuré en version 3 LDAPSetupForVersion3=Serveur LDAP configuré en version 3
LDAPSetupForVersion2=Serveur LDAP configuré en version 2 LDAPSetupForVersion2=Serveur LDAP configuré en version 2
LDAPFieldLoginUnix=Login (unix) LDAPFieldLoginUnix=Login (unix)
LDAPFieldLoginExample=Attribut par défaut : uid LDAPFieldLoginExample=Valeur recommandée : uid
LDAPFilterConnection=Filtre de recherche LDAPFilterConnection=Filtre de recherche
LDAPFilterConnectionExample=Filtre par défaut : &(objectClass=user)(objectCategory=person) LDAPFilterConnectionExample=Valeur recommandée : &(objectClass=user)(objectCategory=person)
LDAPAttributes=Attributs LDAP LDAPAttributes=Attributs LDAP
LDAPFieldLoginSamba=Login (samba, activedirectory) LDAPFieldLoginSamba=Login (samba, activedirectory)
LDAPFieldLoginSambaExample=Attribut par défaut : samaccountname (Samba et ActiveDirectory) LDAPFieldLoginSambaExample=Valeur recommandée : samaccountname (Samba et ActiveDirectory)
LDAPFieldName=Nom LDAPFieldName=Nom
LDAPFieldNameExample=Attribut par défaut : sn LDAPFieldNameExample=Valeur recommandée : sn
LDAPFieldFirstName=Prénom LDAPFieldFirstName=Prénom
LDAPFieldFirstNameExample=Attribut par défaut : givenname LDAPFieldFirstNameExample=Valeur recommandée : givenname
LDAPFieldMail=Adresse E-Mail LDAPFieldMail=Adresse E-Mail
LDAPFieldMailExample=Attribut par défaut : mail LDAPFieldMailExample=Valeur recommandée : mail
LDAPFieldPhone=Numéro de téléphone LDAPFieldPhone=Numéro de téléphone
LDAPFieldPhoneExample=Attribut par défaut : telephonenumber LDAPFieldPhoneExample=Valeur recommandée : telephonenumber
LDAPFieldFax=Numéro de fax LDAPFieldFax=Numéro de fax
LDAPFieldFaxExample=Attribut par défaut : facsimiletelephonenumber LDAPFieldFaxExample=Valeur recommandée : facsimiletelephonenumber
LDAPFieldMobile=Téléphone portable LDAPFieldMobile=Téléphone portable
LDAPFieldMobileExample=Attribut par défaut : mobile LDAPFieldMobileExample=Valeur recommandée : mobile
LDAPParametersAreStillHardCoded=Les parametres LDAP sont codés en dur (dans classe contact) LDAPParametersAreStillHardCoded=Les parametres LDAP sont codés en dur (dans classe contact)
LDAPSetupNotComplete=Configuration LDAP incomplète (à compléter sur les autres onglets) 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. 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.
##### Products ##### ##### Products #####
ProductSetup=Configuration du module Produits ProductSetup=Configuration du module Produits
NumberOfProductShowInSelect=Nombre de produits max dans les listes déroulantes (0=aucune limite) NumberOfProductShowInSelect=Nombre de produits max dans les listes déroulantes (0=aucune limite)

View File

@ -23,16 +23,15 @@
* $Source$ * $Source$
*/ */
/** /**
\file htdocs/lib/authldap.lib.php \file htdocs/lib/authldap.lib.php
\brief Librairie contenant les fonctions pour accèder au serveur ldap. \brief Librairie contenant les fonctions pour accèder au serveur LDAP
\author Rodolphe Quiedeville. \author Rodolphe Quiedeville
\author Benoit Mortier. \author Benoit Mortier
\author Regis Houssin. \author Regis Houssin
\author Laurent Destailleur. \author Laurent Destailleur
\version $Revision$ \version $Revision$
Ensemble des fonctions permettant d'accèder à un serveur LDAP.
*/ */
class AuthLdap { class AuthLdap {
@ -423,6 +422,40 @@ class AuthLdap {
} }
} }
/*
* \brief Add a LDAP entry
* \param dn DN entry key
* \param info Attributes array
* \return boolean <0 si KO, >0 si OK
*/
function add($dn, $info)
{
dolibarr_syslog("authldap::add Add LDAP entry dn=".$dn);
//print_r($info);
$result=@ldap_add($this->connection, $dn, $info);
if ($result) return 1;
return -1;
}
/*
* \brief Delete a LDAP entry
* \param dn DN entry key
* \return boolean <0 si KO, >0 si OK
*/
function delete($dn)
{
dolibarr_syslog("authldap::delete Delete LDAP entry dn=".$dn);
$result=@ldap_delete($this->connection, $dn);
if ($result) return 1;
return -1;
}
// 2.4 Attribute methods ----------------------------------------------------- // 2.4 Attribute methods -----------------------------------------------------
/** /**
* 2.4.1 : Returns an array containing a set of attribute values. * 2.4.1 : Returns an array containing a set of attribute values.

View File

@ -172,9 +172,11 @@ if (! session_id() && ! isset($_SESSION["dol_user"]) && ! isset($_SESSION["dol_
'basedn' => $conf->global->LDAP_SERVER_DN, 'basedn' => $conf->global->LDAP_SERVER_DN,
'binddn' => $conf->global->LDAP_ADMIN_DN, 'binddn' => $conf->global->LDAP_ADMIN_DN,
'bindpw' => $conf->global->LDAP_ADMIN_PASS, 'bindpw' => $conf->global->LDAP_ADMIN_PASS,
//'userattr' => $conf->global->LDAP_FIELD_LOGIN_SAMBA,
'userattr' => 'samAccountName', 'userattr' => $conf->global->LDAP_FIELD_LOGIN_SAMBA,
'userfilter' => '(objectClass=user)', 'userfilter' => $conf->global->$conf->global->LDAP_FILTER_CONNECTION
//'userattr' => 'samAccountName',
//'userfilter' => '(objectClass=user)',
); );
$aDol = new DOLIAuth("LDAP", $params, "dol_loginfunction"); $aDol = new DOLIAuth("LDAP", $params, "dol_loginfunction");

View File

@ -1,57 +0,0 @@
<?PHP
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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$
*
* Mets à jour tous les contacts dans LDAP à partir de la base sql
*/
require_once("../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/user.class.php");
$error = 0;
$user = new User($db);
$sql = "SELECT idp";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople";
$resql = $db->query($sql);
if ( $resql )
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
print "Mise à jour $row[0]\n";
$contact = new Contact($db);
$contact->id = $row[0];
$contact->update_ldap($user);
$i++;
}
}
?>

View File

@ -0,0 +1,90 @@
<?PHP
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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 scripts/company/ldap-update-allcontact.php
\ingroup ldap company
\brief Script de mise a jour des contacts dans LDAP depuis base Dolibarr
*/
// Test si mode batch
$sapi_type = php_sapi_name();
$script_file=__FILE__;
if (eregi('([^\\\/]+)$',$script_file,$reg)) $script_file=$reg[1];
if (substr($sapi_type, 0, 3) == 'cgi') {
echo "Erreur: Vous utilisez l'interpreteur PHP pour le mode CGI. Pour executer $script_file en ligne de commande, vous devez utiliser l'interpreteur PHP pour le mode CLI.\n";
exit;
}
if (! isset($argv[1]) || ! $argv[1]) {
print "Usage: $script_file now\n";
exit;
}
$now=$argv[1];
// Recupere root dolibarr
$path=eregi_replace($script_file,'',$_SERVER["PHP_SELF"]);
require_once($path."../../htdocs/master.inc.php");
require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
require_once(DOL_DOCUMENT_ROOT."/user.class.php");
$user = new User($db);
$sql = "SELECT idp as rowid";
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
print $langs->trans("UpdateContact")." rowid=".$obj->rowid;
$contact = new Contact($db);
$contact->id = $obj->rowid;
$result=$contact->update_ldap($user);
if ($result > 0)
{
print " - ".$langs->trans("OK");
}
else
{
print " - ".$langs->trans("KO").' - '.$contact->error;
}
print "\n";
$i++;
}
}
else
{
dolibarr_print_error($db);
}
?>