Projects
Kolab:3.4
kolab-webadmin
0002-Fix-so-exception-is-thrown-on-alias-addres...
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0002-Fix-so-exception-is-thrown-on-alias-addresses-valida.patch of Package kolab-webadmin (Revision 26)
Currently displaying revision
26
,
Show latest
From e6f1a694efe87e39606580cdf6235110b6395dbe Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Wed, 27 Nov 2013 09:20:31 +0100 Subject: [PATCH 2/2] Fix so exception is thrown on alias addresses validation when one of validated addresses is a primary mail (Bug #2596) --- lib/Auth/LDAP.php | 2 ++ lib/api/kolab_api_service_form_value.php | 25 +++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) 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'; -- 1.8.3.1
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.