seconde version code ldap , contact dans branche people

This commit is contained in:
opensides 2004-06-16 16:29:38 +00:00
parent aec05045b7
commit 46bd2c167f

View File

@ -126,7 +126,7 @@ class Contact
if ($ds) if ($ds)
{ {
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); dolibarr_ldap_setversion($ds,$version);
$ldapbind = dolibarr_ldap_bind($ds); $ldapbind = dolibarr_ldap_bind($ds);
@ -134,7 +134,7 @@ class Contact
{ {
$info["cn"] = utf8_encode($this->firstname." ".$this->name); $info["cn"] = utf8_encode($this->firstname." ".$this->name);
$info["sn"] = utf8_encode($this->name); $info["sn"] = utf8_encode($this->name);
$info["ou"] = "People"; $info["ou"] = People;
if ($this->email) if ($this->email)
$info["rfc822Mailbox"] = $this->email; $info["rfc822Mailbox"] = $this->email;
@ -156,6 +156,7 @@ class Contact
$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->ville) if ($soc->ville)
{ {
$info["l"] = utf8_encode($soc->ville); $info["l"] = utf8_encode($soc->ville);
@ -183,9 +184,10 @@ class Contact
// $info["phpgwCellTelephoneNumber"] = dolibarr_print_phone($this->phone_mobile); // $info["phpgwCellTelephoneNumber"] = dolibarr_print_phone($this->phone_mobile);
//$dn = "uid=".$info["uid"].","."cn=".$info["cn"].", ".LDAP_SERVER_DN ; //$dn = "uid=".$info["uid"].","."cn=".$info["cn"].", ".LDAP_SERVER_DN ;
//$dn = "cn=".$info["cn"].", ".LDAP_SERVER_DN ;
$r = @ldap_delete($ds, LDAP_SERVER_DN); $dn = "cn=".$info["cn"].","."ou=".$info["ou"].", ".LDAP_SERVER_DN_SHORT ;
$r = @ldap_delete($ds, $dn);
if (! ldap_add($ds, $dn, $info)) if (! ldap_add($ds, $dn, $info))
{ {
@ -195,13 +197,15 @@ class Contact
} }
else else
{ {
echo "LDAP bind failed..."; echo "Connection au dn $dn échoué !";
} }
ldap_close($ds);
dolibarr_ldap_unbind($ds);
} }
else else
{ {
echo "Unable to connect to LDAP server"; echo "Impossible de se connecter au serveur LDAP !";
} }
} }