summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-10-22 13:37:44 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-11-26 13:29:47 (GMT)
commit5d73614d72655eaddc5f53c50931d123fd695be8 (patch)
treeb45ea1cdeffe46aaaa7e1ada26cdf0f6b0a8b847
parent376f798d83f568610f771edc6e42f7d48ccb7863 (diff)
downloadkolab-wap-5d73614d72655eaddc5f53c50931d123fd695be8.tar.gz
Fix domain edit/delete by unique attribute
-rw-r--r--lib/Auth/LDAP.php12
-rw-r--r--lib/ext/Net/LDAP3.php5
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 7178559..2891857 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -166,7 +166,9 @@ class LDAP extends Net_LDAP3 {
public function domain_delete($domain)
{
- return $this->entry_delete($domain);
+ $base_dn = $this->conf->get('ldap', 'domain_base_dn');
+
+ return $this->entry_delete($domain, array(), $base_dn);
}
public function domain_find_by_attribute($attribute)
@@ -181,10 +183,10 @@ class LDAP extends Net_LDAP3 {
$this->_log(LOG_DEBUG, "Auth::LDAP::domain_info() for domain " . var_export($domain, true));
$this->bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
- $domain_dn = $this->entry_dn($domain);
+ $domain_base_dn = $this->conf->get('ldap', 'domain_base_dn');
+ $domain_dn = $this->entry_dn($domain, array(), $domain_base_dn);
if (!$domain_dn) {
- $domain_base_dn = $this->conf->get('ldap', 'domain_base_dn');
$domain_filter = $this->conf->get('ldap', 'domain_filter');
$domain_name_attribute = $this->conf->get('ldap', 'domain_name_attribute');
$domain_filter = "(&" . $domain_filter . "(" . $domain_name_attribute . "=" . $domain . "))";
@@ -624,11 +626,11 @@ class LDAP extends Net_LDAP3 {
/**
* delete_entry() wrapper with binding and DN resolving
*/
- protected function entry_delete($entry, $attributes = array())
+ protected function entry_delete($entry, $attributes = array(), $base_dn = null)
{
$this->bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
- $entry_dn = $this->entry_dn($entry, $attributes);
+ $entry_dn = $this->entry_dn($entry, $attributes, $base_dn);
if (!$entry_dn) {
return false;
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 318f7f4..1f0321f 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -636,10 +636,11 @@ class Net_LDAP3
*
* @param string $subject Entry string (e.g. entry DN or unique attribute value)
* @param array $attributes Additional attributes
+ * @param string $base_dn Optional base DN
*
* @return string Entry DN string
*/
- public function entry_dn($subject, $attributes = array())
+ public function entry_dn($subject, $attributes = array(), $base_dn = NULL)
{
$this->_debug("entry_dn on subject $subject");
$is_dn = ldap_explode_dn($subject, 1);
@@ -651,7 +652,7 @@ class Net_LDAP3
$unique_attr = $this->config_get('unique_attribute', 'nsuniqueid');
$attributes = array_merge(array($unique_attr => $subject), (array)$attributes);
- $subject = $this->entry_find_by_attribute($attributes);
+ $subject = $this->entry_find_by_attribute($attributes, $base_dn);
if (!empty($subject)) {
return key($subject);