3 commits - lib/Auth lib/ext

Aleksander Machniak machniak at kolabsys.com
Mon Oct 22 15:38:08 CEST 2012


 lib/Auth/LDAP.php     |   14 +++++++++-----
 lib/ext/Net/LDAP3.php |    9 +++++----
 2 files changed, 14 insertions(+), 9 deletions(-)

New commits:
commit d04bffc6d35cd69160b306c706aae88a215d2769
Author: Aleksander Machniak <alec at alec.pl>
Date:   Mon Oct 22 15:37:44 2012 +0200

    Fix domain edit/delete by unique attribute

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);


commit 6f61efc3f9a623aa64c3c88bc3533cea09a746fc
Author: Aleksander Machniak <alec at alec.pl>
Date:   Mon Oct 22 15:25:24 2012 +0200

    Fix PHP fatal error on wrong _search() result

diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 1428cfc..7178559 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -191,6 +191,7 @@ class LDAP extends Net_LDAP3 {
 
             $this->_log(LOG_DEBUG, "Auth::LDAP::domain_info() uses _search()");
             $result = $this->_search($domain_base_dn, $domain_filter, $attributes);
+            $result = $result->entries(true);
         } else {
             $this->_log(LOG_DEBUG, "Auth::LDAP::domain_info() uses _read()");
             $result = $this->_read($domain_dn, $attributes);
@@ -794,6 +795,7 @@ class LDAP extends Net_LDAP3 {
         );
 
         $subject    = $this->_search($subject_dn);
+        $subject    = $subject->entries(true);
         $attributes = $this->allowed_attributes($subject[$subject_dn]['objectclass']);
         $attributes = array_merge($attributes['may'], $attributes['must']);
 


commit 488d1a71aac31eeb5120c77b6eb7399625f9a48f
Author: Aleksander Machniak <alec at alec.pl>
Date:   Mon Oct 22 14:43:31 2012 +0200

    Remove Auth::LDAP references in debug messages

diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 1f37f3e..318f7f4 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -660,7 +660,7 @@ class Net_LDAP3
 
     public function entry_find_by_attribute($attributes, $base_dn = NULL)
     {
-        $this->_debug("Auth::LDAP::entry_find_by_attribute(\$attributes, \$base_dn) called with base_dn", $base_dn, "and attributes", $attributes);
+        $this->_debug("Net_LDAP3::entry_find_by_attribute(\$attributes, \$base_dn) called with base_dn", $base_dn, "and attributes", $attributes);
 
         if (empty($attributes) || !is_array($attributes)) {
             return FALSE;
@@ -964,7 +964,7 @@ class Net_LDAP3
 
         $rdn_attr = $rdn_components[0];
 
-        $this->_debug("Auth::LDAP::modify_entry() using rdn attribute: " . $rdn_attr);
+        $this->_debug("Net_LDAP3::modify_entry() using rdn attribute: " . $rdn_attr);
 
         $mod_array = array(
             'add'       => array(), // For use with ldap_mod_add()





More information about the commits mailing list