summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-09-06 09:50:29 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-09-06 09:50:54 (GMT)
commitb8f70c69d9a2a5e2ab7f42ab08fe95696236e13d (patch)
treed94ef1358febcc85d6ece2552f55f3aa0bb387c5
parenta1cc945fbb92c835d51202ec09ef489bfb7feb35 (diff)
downloadkolab-wap-b8f70c69d9a2a5e2ab7f42ab08fe95696236e13d.tar.gz
Ensure also the primary mail address is globally unique
-rw-r--r--lib/api/kolab_api_service_form_value.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index e066d8a..f1e0960 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -673,6 +673,33 @@ class kolab_api_service_form_value extends kolab_api_service
$primary_mail = kolab_recipient_policy::primary_mail($postdata);
+ $auth = Auth::get_instance();
+
+ list($_local, $_domain) = explode("@", $primary_mail);
+ $local = $_local;
+
+ $x = 2;
+ while (($user_found = $auth->find_recipient($local . "@" . $_domain))) {
+ Log::trace(__FUNCTION__ . ": An entry with address " . $local . "@" . $_domain . " was found.");
+
+ if (!empty($postdata['id'])) {
+ $user_found_dn = key($user_found);
+ $user_found_unique_attr = $this->unique_attribute_value($user_found_dn);
+
+ if ($user_found_unique_attr == $postdata['id']) {
+ Log::trace(__FUNCTION__ . ": Entry with address " . $local . "@" . $_domain . " is actually us.");
+ break;
+ }
+ } // empty($postdata['id'])
+
+ // Otherwise this is a new user and therefore the entry found with
+ // this address is definitely not us
+ $local = $_local . $x;
+ $x++;
+ }
+
+ $primary_mail = $local . "@" . $_domain;
+
return $primary_mail;
}
}