diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php
index 50736784a39..f6d46952457 100644
--- a/htdocs/admin/ldap.php
+++ b/htdocs/admin/ldap.php
@@ -237,7 +237,16 @@ print '
| '.$langs->trans("DNGroup").' | ';
print '';
print ' |
';
print '| '.$langs->trans("DNContactActive").' | ';
print ' |
';
@@ -246,8 +255,25 @@ print ''
print '';
print '| '.$langs->trans("Type").' | ';
print ' |
';
@@ -266,7 +292,7 @@ if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST) {
}
-if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && $_GET["action"] == 'test')
+if (defined("LDAP_SERVER_HOST") && LDAP_SERVER_HOST && LDAP_ADMIN_DN && LDAP_ADMIN_PASS && $_GET["action"] == 'test')
{
$ds = dolibarr_ldap_connect();
diff --git a/htdocs/contact.class.php b/htdocs/contact.class.php
index f4ef1dadd5c..4dc99fd3328 100644
--- a/htdocs/contact.class.php
+++ b/htdocs/contact.class.php
@@ -178,8 +178,7 @@ class Contact
$info["objectclass"][1] = "person";
$info["objectclass"][2] = "organizationalPerson";
$info["objectclass"][3] = "inetOrgPerson";
-
- $info["ou"] = 'People';
+
$info["cn"] = utf8_encode($this->firstname." ".$this->name);
$info["sn"] = utf8_encode($this->name);
$info["givenName"] = utf8_encode($this->firstname);
@@ -259,13 +258,8 @@ class Contact
$info["mail"] = $this->email;
}
- $dnshort = explode(",", LDAP_ADMIN_DN.','.LDAP_SUFFIX_DN,2);
-
- // TODO comprendre pourquoi cela ne marche plus
- //$dn = "cn=".$info["cn"].","."ou=".$info["ou"].",".$dnshort[1];
+ $dn = "cn=".$info["cn"].",".LDAP_CONTACT_DN.",".LDAP_SUFFIX_DN;
- $dn = "cn=".$info["cn"].",".$dnshort[1];
-
$r = @ldap_delete($ds, $dn);
if (! @ldap_add($ds, $dn, $info))
@@ -275,7 +269,7 @@ class Contact
}
else
{
- echo "Connection au dn $dn échoué !";
+ echo "Connexion au dn $dn échoué !";
}
dolibarr_ldap_unbind($ds);
@@ -487,6 +481,20 @@ class Contact
*/
function delete($id)
{
+ $sql = "SELECT c.name, c.firstname FROM ".MAIN_DB_PREFIX."socpeople as c";
+ $sql .= " WHERE c.idp = ". $id;
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->old_name = $obj->name;
+ $this->old_firstname = $obj->firstname;
+ }
+ }
+
$sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
$sql .= " WHERE idp=$id";
@@ -500,32 +508,23 @@ class Contact
if (defined('MAIN_MODULE_LDAP') && MAIN_MODULE_LDAP)
{
if (defined('LDAP_CONTACT_ACTIVE') && LDAP_CONTACT_ACTIVE == 1)
+ {
- $this->update_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, $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_SUFFIX_DN);
+ $userdn = utf8_encode($this->old_firstname." ".$this->old_name);
+ $dn = "cn=".$userdn.",".LDAP_CONTACT_DN.",".LDAP_SUFFIX_DN;
$r = @ldap_delete($ds, $dn);
+
}
else
{
@@ -542,6 +541,8 @@ class Contact
return $result;
}
+ }
+}
/*
* \brief Charge les informations sur le contact, depuis la base
diff --git a/htdocs/includes/modules/modLdap.class.php b/htdocs/includes/modules/modLdap.class.php
index c2d70a5f458..406d493ca78 100644
--- a/htdocs/includes/modules/modLdap.class.php
+++ b/htdocs/includes/modules/modLdap.class.php
@@ -1,6 +1,7 @@
* 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
@@ -51,7 +52,7 @@ class modLdap extends DolibarrModules
$this->name = "Ldap";
$this->family = "technic";
$this->description = "Synchronisation Ldap";
- $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
+ $this->version = 'experimental'; // 'experimental' or 'dolibarr' or version
$this->const_name = "MAIN_MODULE_LDAP";
$this->const_config = MAIN_MODULE_LDAP;
$this->special = 1;
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index ea6a5d0a994..c295013af66 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -282,7 +282,7 @@ DNContactActiveYes=Activated synchronization
DNContactActiveExample=Desactivated synchronization
DNContact=Contacts' DN
DNContactExample=ex: ou=contacts
-TypeExample=OpenLdap or Egroupware
+TypeExample=OpenLdap, Egroupware or Active Directory
##### Propal #####
PropalSetup=Commercial proposals module setup
##### Sendings #####
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 33f741143a1..03d799f6260 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -282,7 +282,7 @@ DNContactActiveYes=Synchronisation activ
DNContact=DN des contacts
DNContactActiveExample=Synchronisation désactivée
DNContactExample=ex: ou=contacts
-TypeExample=OpenLdap ou Egroupware
+TypeExample=OpenLdap, Egroupware ou Active Directory
##### Propal #####
PropalSetup=Configuration du module Propositions Commerciales
##### Sendings #####
diff --git a/htdocs/lib/ldap.lib.php b/htdocs/lib/ldap.lib.php
index db453756702..b5fcd24e26c 100644
--- a/htdocs/lib/ldap.lib.php
+++ b/htdocs/lib/ldap.lib.php
@@ -54,12 +54,19 @@ function dolibarr_ldap_connect()
function dolibarr_ldap_bind($ds)
{
- if (defined("LDAP_ADMIN_PASS") && LDAP_SUFFIX_DN && LDAP_ADMIN_DN && LDAP_ADMIN_PASS)
+ if (defined("LDAP_ADMIN_PASS") && LDAP_SUFFIX_DN && LDAP_ADMIN_DN && LDAP_ADMIN_PASS)
{
- $ldapbind = ldap_bind($ds, LDAP_ADMIN_DN.",".LDAP_SUFFIX_DN, LDAP_ADMIN_PASS);
- }
+ if (defined("LDAP_SERVER_TYPE") && LDAP_USER_DN && LDAP_SERVER_TYPE == activedirectory)
+ {
+ $ldapbind = ldap_bind($ds, LDAP_ADMIN_DN.",".LDAP_USER_DN.",".LDAP_SUFFIX_DN, LDAP_ADMIN_PASS);
+ }
+ else
+ {
+ $ldapbind = ldap_bind($ds, LDAP_ADMIN_DN.",".LDAP_SUFFIX_DN, LDAP_ADMIN_PASS);
+ }
- return $ldapbind;
+ return $ldapbind;
+ }
}
/*!