Modification pour la gestion des utilisateurs via LDAP

This commit is contained in:
Regis Houssin 2005-07-10 17:27:51 +00:00
parent 650c031a69
commit 05cbdcb946

View File

@ -2,6 +2,7 @@
/* 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 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
* 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
* it under the terms of the GNU General Public License as published by * 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 * \param id id du contact a effacer
*/ */
function delete($id) function delete($id)
@ -494,18 +495,28 @@ class Contact
if (defined('MAIN_MODULE_LDAP') && MAIN_MODULE_LDAP) 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(); $ds = dolibarr_ldap_connect();
if ($ds) 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); $ldapbind = dolibarr_ldap_bind($ds);
if ($ldapbind) if ($ldapbind)
{ {
// delete from ldap directory // 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);
} }
@ -520,7 +531,7 @@ class Contact
{ {
echo "Unable to connect to LDAP server"; echo "Unable to connect to LDAP server";
} }
}
return $result; return $result;
} }