summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-11-27 08:20:31 (GMT)
committerAleksander Machniak <alec@alec.pl>2013-11-27 08:22:03 (GMT)
commite6f1a694efe87e39606580cdf6235110b6395dbe (patch)
tree151455cf4101984f6d807cf7f922c7aa9d1d1dfc
parent56a5b6d36535025933270842a3aa80f16d67c0ee (diff)
downloadkolab-wap-e6f1a694efe87e39606580cdf6235110b6395dbe.tar.gz
Fix so exception is thrown on alias addresses validation when
one of validated addresses is a primary mail (Bug #2596)
-rw-r--r--lib/Auth/LDAP.php2
-rw-r--r--lib/api/kolab_api_service_form_value.php25
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';