diff --git a/setup/class_setupStep_Config.inc b/setup/class_setupStep_Config.inc index 269312c443de788ab5c66fa079cf6abd8b52fc24..ee17ba8f736a4db64bc16c4a4bb1ffcdf91ec834 100644 --- a/setup/class_setupStep_Config.inc +++ b/setup/class_setupStep_Config.inc @@ -98,6 +98,13 @@ class Step_Config extends configInLdap parent::save_object(); $tmp = $this->check(); if (count($tmp) == 0) { + /* Create root object if missing */ + $ldap = $config->get_ldap_link(); + $ldap->cd($config->current['BASE']); + $ldap->create_missing_trees($config->current['BASE']); + if (!$ldap->success()) { + return msgPool::ldaperror($ldap->get_error(), $config->current['BASE'], 'create_missing_trees', get_class()); + } /* Save in LDAP */ $this->save(); /* Reload config from LDAP */ diff --git a/setup/class_setupStep_Migrate.inc b/setup/class_setupStep_Migrate.inc index a1da9131aa6df643a34ba72d8d74e6e0d0428c2e..47b6fa625b38e5fb82fcb738fba5f04818293bb4 100644 --- a/setup/class_setupStep_Migrate.inc +++ b/setup/class_setupStep_Migrate.inc @@ -255,7 +255,6 @@ class Step_Migrate extends setupStep $config->get_departments(); $checks = array( - 'base' => new StepMigrateCheck($this, 'base', _('Checking for root object')), 'baseOC' => new StepMigrateCheck($this, 'baseOC', _('Inspecting object classes in root object')), 'permissions' => new StepMigrateCheck($this, 'permissions', _('Checking permission for LDAP database')), 'gosaAccounts' => new StepMigrateCheck($this, 'gosaAccounts', _('Checking for invisible users')), @@ -313,53 +312,6 @@ class Step_Migrate extends setupStep } } - /* Check if the root object exists. - * If the parameter just_check is TRUE, then just check if the - * root object is missing and update the info messages. - * If the Parameter is FALSE, try to create a new root object. - */ - function check_base(&$checkobj) - { - global $config; - - $ldap = $config->get_ldap_link(); - - /* Check if root object exists */ - $ldap->cd($config->current['BASE']); - $ldap->set_size_limit(1); - $res = $ldap->search("(objectClass=*)"); - $ldap->set_size_limit(0); - $err = ldap_errno($ldap->cid); - - if ( !$res || - $err == 0x20 || // LDAP_NO_SUCH_OBJECT - $err == 0x40) { // LDAP_NAMING_VIOLATION - - /* Root object doesn't exists */ - throw new CheckFailedException( - _('Failed'), - _('The LDAP root object is missing. It is required to use your LDAP service.').' '. - $checkobj->submit(_('Try to create root object'), 'create') - ); - } - - /* Root object exists */ - return ''; - } - - function check_base_create (&$checkobj) - { - global $config; - - $ldap = $config->get_ldap_link(); - - /* Add root object */ - $ldap->cd($config->current['BASE']); - $ldap->create_missing_trees($config->current['BASE']); - /* Re-run test */ - $checkobj->run(); - } - /* Check if the root object includes the required object classes, e.g. gosaDepartment is required for ACLs. * If the parameter just_check is TRUE, then just check for the OCs. * If the Parameter is FALSE, try to add the required object classes.