Gestion de LDAP si le module est activé
This commit is contained in:
parent
3908d6fce9
commit
d2c090e3ac
@ -94,60 +94,61 @@ class Contact
|
|||||||
print $this->db->error() . '<br>' . $sql;
|
print $this->db->error() . '<br>' . $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ds = dolibarr_ldap_connect();
|
if (define('MAIN_MODULE_LDAP') && MAIN_MODULE_LDAP)
|
||||||
|
|
||||||
if ($ds)
|
|
||||||
{
|
{
|
||||||
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
|
$ds = dolibarr_ldap_connect();
|
||||||
|
|
||||||
$ldapbind = dolibarr_ldap_bind($ds);
|
if ($ds)
|
||||||
|
|
||||||
if ($ldapbind)
|
|
||||||
{
|
{
|
||||||
$info["cn"] = utf8_encode($this->firstname." ".$this->name);
|
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||||
$info["sn"] = utf8_encode($this->name);
|
|
||||||
|
|
||||||
if ($this->email)
|
$ldapbind = dolibarr_ldap_bind($ds);
|
||||||
$info["rfc822Mailbox"] = $this->email;
|
|
||||||
|
|
||||||
if ($this->phone_pro)
|
if ($ldapbind)
|
||||||
$info["telephoneNumber"] = dolibarr_print_phone($this->phone_pro);
|
|
||||||
|
|
||||||
if ($this->phone_mobile)
|
|
||||||
$info["mobile"] = dolibarr_print_phone($this->phone_mobile);
|
|
||||||
|
|
||||||
if ($this->phone_perso)
|
|
||||||
$info["homePhone"] = dolibarr_print_phone($this->phone_perso);
|
|
||||||
|
|
||||||
if ($this->poste)
|
|
||||||
$info["title"] = utf8_encode($this->poste);
|
|
||||||
|
|
||||||
//$info["homePostalAddress"] = "AdressePersonnelle\nVIlle";
|
|
||||||
//$info["street"] = "street";
|
|
||||||
//$info["postalCode"] = "postalCode";
|
|
||||||
//$info["postalAddress"] = "postalAddress";
|
|
||||||
|
|
||||||
$info["objectclass"] = "inetOrgPerson";
|
|
||||||
|
|
||||||
// add data to directory
|
|
||||||
$dn = utf8_encode("cn=".$this->old_firstname." ".$this->old_name).", ".LDAP_SERVER_DN ;
|
|
||||||
|
|
||||||
$r = @ldap_delete($ds, $dn);
|
|
||||||
|
|
||||||
$dn = "cn=".$info["cn"].", ".LDAP_SERVER_DN ;
|
|
||||||
|
|
||||||
if (! ldap_add($ds, $dn, $info))
|
|
||||||
{
|
{
|
||||||
print ldap_errno();
|
$info["cn"] = utf8_encode($this->firstname." ".$this->name);
|
||||||
|
$info["sn"] = utf8_encode($this->name);
|
||||||
|
|
||||||
|
if ($this->email)
|
||||||
|
$info["rfc822Mailbox"] = $this->email;
|
||||||
|
|
||||||
|
if ($this->phone_pro)
|
||||||
|
$info["telephoneNumber"] = dolibarr_print_phone($this->phone_pro);
|
||||||
|
|
||||||
|
if ($this->phone_mobile)
|
||||||
|
$info["mobile"] = dolibarr_print_phone($this->phone_mobile);
|
||||||
|
|
||||||
|
if ($this->phone_perso)
|
||||||
|
$info["homePhone"] = dolibarr_print_phone($this->phone_perso);
|
||||||
|
|
||||||
|
if ($this->poste)
|
||||||
|
$info["title"] = utf8_encode($this->poste);
|
||||||
|
|
||||||
|
//$info["homePostalAddress"] = "AdressePersonnelle\nVIlle";
|
||||||
|
//$info["street"] = "street";
|
||||||
|
//$info["postalCode"] = "postalCode";
|
||||||
|
//$info["postalAddress"] = "postalAddress";
|
||||||
|
|
||||||
|
$info["objectclass"] = "inetOrgPerson";
|
||||||
|
|
||||||
|
// add data to directory
|
||||||
|
$dn = utf8_encode("cn=".$this->old_firstname." ".$this->old_name).", ".LDAP_SERVER_DN ;
|
||||||
|
|
||||||
|
$r = @ldap_delete($ds, $dn);
|
||||||
|
|
||||||
|
$dn = "cn=".$info["cn"].", ".LDAP_SERVER_DN ;
|
||||||
|
|
||||||
|
if (! ldap_add($ds, $dn, $info))
|
||||||
|
{
|
||||||
|
print ldap_errno();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "LDAP bind failed...";
|
||||||
|
}
|
||||||
|
ldap_close($ds);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
echo "LDAP bind failed...";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ldap_close($ds);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -156,6 +157,29 @@ class Contact
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mise à jour des infos persos
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
Function update_perso($id, $user=0)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "UPDATE llx_socpeople SET ";
|
||||||
|
$sql .= " birthday='".$db->idate($this->birthday)."'";
|
||||||
|
$sql .= " WHERE idp=$id";
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
|
if (!$result)
|
||||||
|
{
|
||||||
|
print $this->db->error() . '<br>' . $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
@ -241,28 +265,29 @@ class Contact
|
|||||||
print $this->db->error() . '<br>' . $sql;
|
print $this->db->error() . '<br>' . $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ds = dolibarr_ldap_connect();
|
if (define('MAIN_MODULE_LDAP') && MAIN_MODULE_LDAP)
|
||||||
|
|
||||||
if ($ds)
|
|
||||||
{
|
{
|
||||||
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
|
$ds = dolibarr_ldap_connect();
|
||||||
|
|
||||||
$ldapbind = dolibarr_ldap_bind($ds);
|
if ($ds)
|
||||||
|
|
||||||
if ($ldapbind)
|
|
||||||
{
|
{
|
||||||
// delete from ldap directory
|
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||||
$dn = utf8_encode("cn=".$this->old_firstname." ".$this->old_name.", ".LDAP_SERVER_DN) ;
|
|
||||||
|
|
||||||
$r = @ldap_delete($ds, $dn);
|
$ldapbind = dolibarr_ldap_bind($ds);
|
||||||
|
|
||||||
|
if ($ldapbind)
|
||||||
|
{
|
||||||
|
// delete from ldap directory
|
||||||
|
$dn = utf8_encode("cn=".$this->old_firstname." ".$this->old_name.", ".LDAP_SERVER_DN) ;
|
||||||
|
|
||||||
|
$r = @ldap_delete($ds, $dn);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "LDAP bind failed...";
|
||||||
|
}
|
||||||
|
ldap_close($ds);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
echo "LDAP bind failed...";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ldap_close($ds);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user