summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-02-27 15:28:44 +0100
committerAleksander Machniak <machniak@kolabsys.com>2014-02-27 15:28:44 +0100
commit8e09ba6962f63bfcb0dcd6eee92250b352bec895 (patch)
tree013b0de7f3387d7d944ce511b4a51d258b2eb69a
parent4a55f2c1d856a3e7d44ab03d31ceca7bee86afda (diff)
downloadwebadmin-8e09ba6962f63bfcb0dcd6eee92250b352bec895.tar.gz
Return ID also in domain.add response
-rw-r--r--lib/Auth/LDAP.php6
-rw-r--r--lib/api/kolab_api_service_domain.php20
2 files changed, 18 insertions, 8 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 898a60d..25bef97 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -178,9 +178,9 @@ class LDAP extends Net_LDAP3 {
array_unshift($attributes[$domain_name_attribute], $domain);
}
- $dn = $domain_name_attribute . '=' . $domain . ',' . $domain_base_dn;
+ $domain_dn = $domain_name_attribute . '=' . $domain . ',' . $domain_base_dn;
- $result = $this->add_entry($dn, $attributes);
+ $result = $this->add_entry($domain_dn, $attributes);
if (!$result) {
return false;
@@ -369,7 +369,7 @@ class LDAP extends Net_LDAP3 {
$this->add_entry($dn, $attrs);
}
- return true;
+ return $domain_dn;
}
public function domain_edit($domain, $attributes, $typeid = null)
diff --git a/lib/api/kolab_api_service_domain.php b/lib/api/kolab_api_service_domain.php
index 711b37b..6b82d0d 100644
--- a/lib/api/kolab_api_service_domain.php
+++ b/lib/api/kolab_api_service_domain.php
@@ -77,7 +77,7 @@ class kolab_api_service_domain extends kolab_api_service
Log::trace("domain.add(\$getdata = " . var_export($getdata, TRUE) . ", \$postdata = " . var_export($postdata, TRUE) . ")");
$conf = Conf::get_instance();
- $dna = $conf->get('domain_name_attribute');
+ $dna = $conf->get('domain_name_attribute');
if (empty($dna)) {
$dna = 'associateddomain';
@@ -91,11 +91,21 @@ class kolab_api_service_domain extends kolab_api_service
$auth = Auth::get_instance($conf->get('kolab', 'primary_domain'));
// parse input attributes
- $domain_attributes = $this->parse_input_attributes('domain', $postdata);
- $domain_attributes[$dna] = (array)$domain_attributes[$dna];
- $domain = array_shift($domain_attributes[$dna]);
+ $attributes = $this->parse_input_attributes('domain', $postdata);
+ $attributes[$dna] = (array) $attributes[$dna];
+ $domain = array_shift($attributes[$dna]);
+
+ $result = $auth->domain_add($domain, $attributes);
+
+ if ($result) {
+ if ($id = $this->unique_attribute_value($result)) {
+ $attributes['id'] = $id;
+ }
+
+ return $attributes;
+ }
- return $auth->domain_add($domain, $domain_attributes);
+ return false;
}
/**