Verified Commit 533ee388 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

🚑 fix(plugins) Adapt code to create_missing_trees error handling

issue #6061
parent acb523a1
......@@ -131,7 +131,11 @@ class dhcpConfiguration extends simplePlugin
/* Save dhcp settings */
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
$ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
try {
$ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
} catch (FusionDirectoryError $error) {
return [$error];
}
$cache = $this->attributesAccess['dhcpSections']->getCache();
$errors = [];
$new = ($this->orig_dn == 'new');
......
......@@ -235,9 +235,10 @@ class serviceRepository extends simpleService
$ldap->cat($fai, ['dn']);
if (!$ldap->count()) {
$ldap->cd($config->current['BASE']);
$ldap->create_missing_trees($fai);
if (!$ldap->success()) {
msg_dialog::display(_('LDAP error'), msgPool::ldaperror($ldap->get_error(), $fai, LDAP_ADD, get_class()), LDAP_ERROR);
try {
$ldap->create_missing_trees($fai);
} catch (FusionDirectoryError $error) {
$error->display();
return;
}
}
......@@ -252,9 +253,10 @@ class serviceRepository extends simpleService
// Add classes OUs
foreach (['Script', 'Hook', 'Template', 'Variable', 'Profile', 'Package', 'Partition'] as $type) {
$ldap->cd($dn);
$ldap->create_missing_trees(get_ou('fai'.$type.'RDN').$dn);
if (!$ldap->success()) {
msg_dialog::display(_('LDAP error'), msgPool::ldaperror($ldap->get_error(), get_ou('fai'.$type.'RDN').$dn, LDAP_ADD, get_class()), LDAP_ERROR);
try {
$ldap->create_missing_trees(get_ou('fai'.$type.'RDN').$dn);
} catch (FusionDirectoryError $error) {
$error->display();
}
}
} else {
......
......@@ -114,7 +114,11 @@ if (preg_match('/QUERY>PROLOG<\/QUERY/', $xml)) {
} else {
/* Make sure branch is existing */
$ldap->cd($config->current['BASE']);
$ldap->create_missing_trees(get_ou('inventoryRDN').$config->current['BASE']);
try {
$ldap->create_missing_trees(get_ou('inventoryRDN').$config->current['BASE']);
} catch (FusionDirectoryError $error) {
returnError($error->getMessage());
}
}
/* Create root node */
$ldap->cd($dn);
......
......@@ -95,15 +95,10 @@ class pgpServerInfo extends simplePlugin
if (!$ldap->count()) {
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->pgpBaseKeySpaceDN, "Creating branch");
$ldap->cd($config->current['BASE']);
$ldap->create_missing_trees($this->pgpBaseKeySpaceDN);
if (!$ldap->success()) {
$errors[] = new SimplePluginLdapError(
$this,
$this->pgpBaseKeySpaceDN,
LDAP_ADD,
$ldap->get_error(),
$ldap->get_errno()
);
try {
$ldap->create_missing_trees($this->pgpBaseKeySpaceDN);
} catch (FusionDirectoryError $error) {
$errors[] = SimplePluginError::relocate($this, $error);
}
}
/* Delete the old branch if empty */
......
......@@ -203,7 +203,11 @@ class userReminderConfig extends simplePlugin
global $config;
$ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']);
$ldap->create_missing_trees(get_ou('reminderTokenRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']);
try {
$ldap->create_missing_trees(get_ou('reminderTokenRDN').get_ou('fusiondirectoryRDN').$config->current['BASE']);
} catch (FusionDirectoryError $error) {
$error->display();
}
parent::post_save();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment