summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Hoffend <dh@dotlan.net>2020-02-25 10:07:03 +0100
committerJeroen van Meeuwen <kanarip@kanarip.ch>2020-02-25 10:07:03 +0100
commitd2ccdefe6c7bfcd33a7a46feed380cc9a3deff40 (patch)
tree0709b84d66b38ba1e6a2a6ce4f8793f7b32359e6
parentfa1ff0c3a21bbceeca674858b72c9391187d3d74 (diff)
downloadwebadmin-master.tar.gz
Preserve important old aci and inetdomainbasedn attributes of the mgmt and hosted domainHEADmaster
Summary: This changes preservers the inetdomainbasedn for hosted and management when they're getting edited in the kolab-webadmin when hosted_mode is activated. Test Plan: Edit the mgmt or hosted domain using cn=Directory Manager. Your inetdomainbased will change from dc=hosted,dc=com to ou=hosted.com,dc=hosted,dc=com Reviewers: #web_administration_panel_developers, vanmeeuwen Reviewed By: #web_administration_panel_developers, vanmeeuwen Differential Revision: https://git.kolab.org/D907
-rw-r--r--lib/api/kolab_api_service_domain.php31
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/api/kolab_api_service_domain.php b/lib/api/kolab_api_service_domain.php
index 9781eeb..8803109 100644
--- a/lib/api/kolab_api_service_domain.php
+++ b/lib/api/kolab_api_service_domain.php
@@ -174,7 +174,7 @@ class kolab_api_service_domain extends kolab_api_service
$attributes = $this->parse_input_attributes('domain', $postdata, $postdata['type_id']);
- $this->_mod_domain_attrs(null, $attributes);
+ $this->_mod_domain_attrs(null, $attributes, $postdata['id']);
$result = $auth->domain_edit($postdata['id'], $attributes, $postdata['type_id']);
@@ -278,7 +278,7 @@ class kolab_api_service_domain extends kolab_api_service
/**
* Modify hosted domain attributes
*/
- protected function _mod_domain_attrs($domain, &$attributes)
+ protected function _mod_domain_attrs($domain, &$attributes, $olddn = null)
{
// Generate attributes (aci, inetdomainbasedn) for hosted domains
$conf = Conf::get_instance();
@@ -328,8 +328,31 @@ class kolab_api_service_domain extends kolab_api_service
. 'ldap:///cn=kolab-admin,' . $mgmt_root_dn . '");)'
);
- $attributes['aci'] = $aci;
- $attributes['inetdomainbasedn'] = $domain_root_dn;
+ // Preserve important old aci and inetdomainbasedn attributes of the
+ // management and hosted domain.
+ if (!empty($olddn)) {
+ $auth = Auth::get_instance();
+ $info = $auth->domain_info($olddn);
+ if (!empty($info)) {
+ $oldattributes = reset($info);
+ if (!empty($oldattributes['inetdomainbasedn'])
+ && $oldattributes['inetdomainbasedn'] == $hosted_root_dn
+ || "dc=".implode(",dc=",explode(".",$domain)) == $mgmt_root_dn
+ ) {
+ $aci = $oldattributes['aci'];
+ if (!empty($oldattributes['inetdomainbasedn'])) {
+ $domain_root_dn = $oldattributes['inetdomainbasedn'];
+ } else {
+ $domain_root_dn = null;
+ }
+ }
+ }
+ }
+
+ $attributes['aci'] = $aci;
+ if (!empty($domain_root_dn)) {
+ $attributes['inetdomainbasedn'] = $domain_root_dn;
+ }
$this->is_hosted = true;
}