summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/kolab_api_controller.php37
-rw-r--r--lib/kolab_client_task.php24
2 files changed, 33 insertions, 28 deletions
diff --git a/lib/kolab_api_controller.php b/lib/kolab_api_controller.php
index e0dbf8b..f5e67d7 100644
--- a/lib/kolab_api_controller.php
+++ b/lib/kolab_api_controller.php
@@ -282,7 +282,29 @@ class kolab_api_controller
session_start();
$_SESSION['user'] = new User();
- $valid = $_SESSION['user']->authenticate($postdata['username'], $postdata['password'], $postdata['domain']);
+
+ if (empty($postdata['domain'])) {
+ Log::debug("No login domain specified. Attempting to derive from username.");
+ if (count(explode('@', $postdata['username'])) > 1) {
+ $login = explode('@', $postdata['username']);
+ $username = array_shift($login);
+ $domain = array_shift($login);
+ }
+ else {
+ Log::debug("No domain name space in the username, using the primary domain");
+ $conf = Conf::get_instance();
+ $domain = $conf->get('kolab', 'primary_domain');
+ }
+ }
+ else {
+ $domain = $postdata['domain'];
+ }
+
+ if (empty($username)) {
+ $username = $postdata['username'];
+ }
+
+ $valid = $_SESSION['user']->authenticate($username, $postdata['password'], $domain);
// start new (PHP) session
if ($valid) {
@@ -308,6 +330,13 @@ class kolab_api_controller
$auth = Auth::get_instance();
+ // Get the domain name attribute
+ $conf = Conf::get_instance();
+ $dna = $conf->get('ldap', 'domain_name_attribute');
+ if (empty($dna)) {
+ $dna = 'associateddomain';
+ }
+
$this->domains = $auth->list_domains();
$result = array();
@@ -323,9 +352,9 @@ class kolab_api_controller
// add capabilities of all registered services
foreach ($this->domains as $domain) {
- // TODO: 'associateddomain' is very specific to 389ds based deployments, and this
- // is supposed to be very generic.
- $domain_name = is_array($domain) ? (is_array($domain['associateddomain']) ? $domain['associateddomain'][0] : $domain['associateddomain']) : $domain;
+
+ $domain_name = is_array($domain) ? (is_array($domain[$dna]) ? $domain[$dna][0] : $domain[$dna]) : $domain;
+
// define our very own capabilities
$actions = array(
'system.quit' => array('type' => 'w'),
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index b41d75b..1352ef4 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -635,22 +635,8 @@ class kolab_client_task
$auth = Auth::get_instance();
$conf = Conf::get_instance();
- $dna = $conf->get('domain_name_attribute');
$auth->connect();
- $domains = Array();
- $_domains = $auth->list_domains();
-
- foreach ($_domains as $domain_dn => $domain_attrs) {
- if (is_array($domain_attrs[$dna])) {
- $domain = array_shift($domain_attrs[$dna]);
- } else {
- $domain = $domain_attrs[$dna];
- }
-
- $domains[$domain] = $domain;
- }
-
$username = kolab_html::label(array(
'for' => 'login_name',
'content' => $this->translate('login.username')), true)
@@ -670,15 +656,6 @@ class kolab_client_task
'name' => 'login[password]',
'value' => ''));
- $domain = kolab_html::label(array(
- 'for' => 'login_domain',
- 'content' => $this->translate('login.domain')), true)
- . kolab_html::select(array(
- 'type' => 'select',
- 'id' => 'login_domain',
- 'name' => 'login[domain]',
- 'options' => $domains));
-
$button = kolab_html::input(array(
'type' => 'submit',
'id' => 'login_submit',
@@ -691,7 +668,6 @@ class kolab_client_task
'action' => '?'),
kolab_html::span(array('content' => $username))
. kolab_html::span(array('content' => $password))
- . kolab_html::span(array('content' => $domain))
. $button);
return $form;