From 05cbdcb946f22f6973368fa92859a6ca2474dbf3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 10 Jul 2005 17:27:51 +0000 Subject: [PATCH] Modification pour la gestion des utilisateurs via LDAP --- htdocs/contact.class.php | 53 ++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php index 6b9dd27e25c..3232bb4dbfe 100644 --- a/htdocs/contact.class.php +++ b/htdocs/contact.class.php @@ -2,6 +2,7 @@ /* Copyright (C) 2002-2004 Rodolphe Quiedeville * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Laurent Destailleur + * Copyright (C) 2005 Regis Houssin * * 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 @@ -477,7 +478,7 @@ class Contact /* - * \brief Efface le contacte de la base et éventuellement de l'annuaire LDAP + * \brief Efface le contact de la base et éventuellement de l'annuaire LDAP * \param id id du contact a effacer */ function delete($id) @@ -488,39 +489,49 @@ class Contact $result = $this->db->query($sql); if (!$result) - { - print $this->db->error() . '
' . $sql; - } + { + print $this->db->error() . '
' . $sql; + } - if (defined('MAIN_MODULE_LDAP') && MAIN_MODULE_LDAP) - { - $ds = dolibarr_ldap_connect(); + if (defined('MAIN_MODULE_LDAP') && MAIN_MODULE_LDAP) + { + $this->delete_ldap($user); + } + return $result; + } + + function delete_ldap($user) + { + $this->fetch($this->id); + + $ds = dolibarr_ldap_connect(); if ($ds) { - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); - + //ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); + //ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $version); + dolibarr_ldap_setversion($ds, $version); $ldapbind = dolibarr_ldap_bind($ds); if ($ldapbind) - { + { // delete from ldap directory - $dn = utf8_encode("cn=".$this->old_firstname." ".$this->old_name.", ".LDAP_SERVER_DN) ; + $dn = utf8_encode("cn=".$this->old_firstname." ".$this->old_name.", ".LDAP_SUFFIX_DN); - $r = @ldap_delete($ds, $dn); - } + $r = @ldap_delete($ds, $dn); + } else - { - echo "LDAP bind failed..."; - } - ldap_close($ds); + { + echo "LDAP bind failed..."; + } + ldap_close($ds); - } + } else - { + { echo "Unable to connect to LDAP server"; - } - } + } + return $result; }