Branch 'kolab-webadmin-3.1' - lib/api lib/Auth

Aleksander Machniak machniak at kolabsys.com
Wed Nov 27 09:22:11 CET 2013


 lib/Auth/LDAP.php                        |    2 ++
 lib/api/kolab_api_service_form_value.php |   25 +++++++++++++++++++++----
 2 files changed, 23 insertions(+), 4 deletions(-)

New commits:
commit e6f1a694efe87e39606580cdf6235110b6395dbe
Author: Aleksander Machniak <alec at alec.pl>
Date:   Wed Nov 27 09:20:31 2013 +0100

    Fix so exception is thrown on alias addresses validation when
    one of validated addresses is a primary mail (Bug #2596)

diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index bf02ba1..7de9017 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -605,6 +605,8 @@ class LDAP extends Net_LDAP3 {
             );
         }
 
+        $this->config_set('return_attributes', $mail_attrs);
+
         $result = $this->search_entries($this->config_get('root_dn'), '(objectclass=*)', 'sub', null, $search);
 
         if ($result && $result->count() > 0) {
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 3ea1670..1d47a9c 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -1070,7 +1070,7 @@ class kolab_api_service_form_value extends kolab_api_service
      * Checks if specified list of email addresses is already
      * in use by another user
      */
-    private function _email_addresses_in_use($addresses, $postdata)
+    private function _email_addresses_in_use($addresses, $attr_name, $postdata)
     {
         $auth = Auth::get_instance();
 
@@ -1083,8 +1083,25 @@ class kolab_api_service_form_value extends kolab_api_service
                     $user_found_unique_attr = $this->unique_attribute_value($user_found_dn);
 
                     if ($user_found_unique_attr == $postdata['id']) {
-                        Log::trace(__FUNCTION__ . ": Entry with address $addr is actually us.");
-                        continue;
+                        // check if the address is in another field, we prevent here
+                        // from e.g. adding primary mail address into aliases list
+                        $found = false;
+                        $user  = $users[$user_found_dn];
+                        unset($user[$attr_name]);
+
+                        foreach ($user as $attr => $list) {
+                            if (in_array($addr, (array) $list)) {
+                                $found = true;
+                                break;
+                            }
+                        }
+
+                        if (!$found) {
+                            Log::trace(__FUNCTION__ . ": Entry with address $addr is actually us.");
+                            continue;
+                        }
+
+                        // @TODO: throw different exception?
                     }
                 }
 
@@ -1121,7 +1138,7 @@ class kolab_api_service_form_value extends kolab_api_service
 
         // Check if addresses are not already in use
         if ($validation_type == self::VALIDATE_EXTENDED) {
-            $this->_email_addresses_in_use($value, $postdata);
+            $this->_email_addresses_in_use($value, 'alias', $postdata);
         }
 
         return 'OK';




More information about the commits mailing list