lib/api lib/Auth
Aleksander Machniak
machniak at kolabsys.com
Wed Nov 27 09:21:36 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 00d43c3f2ef02f1c2188e5dd96cb255cac8268a1
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 f4015c4..0ac7420 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -1067,7 +1067,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();
@@ -1080,8 +1080,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?
}
}
@@ -1118,7 +1135,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