Verified Commit 8f1978c8 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(plugins) Adapt code to create_missing_trees error handling

issue #6061
parent 92cc980a
No related merge requests found
Showing with 27 additions and 18 deletions
+27 -18
...@@ -131,7 +131,11 @@ class dhcpConfiguration extends simplePlugin ...@@ -131,7 +131,11 @@ class dhcpConfiguration extends simplePlugin
/* Save dhcp settings */ /* Save dhcp settings */
$ldap = $config->get_ldap_link(); $ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']); $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(); $cache = $this->attributesAccess['dhcpSections']->getCache();
$errors = []; $errors = [];
$new = ($this->orig_dn == 'new'); $new = ($this->orig_dn == 'new');
......
...@@ -235,9 +235,10 @@ class serviceRepository extends simpleService ...@@ -235,9 +235,10 @@ class serviceRepository extends simpleService
$ldap->cat($fai, ['dn']); $ldap->cat($fai, ['dn']);
if (!$ldap->count()) { if (!$ldap->count()) {
$ldap->cd($config->current['BASE']); $ldap->cd($config->current['BASE']);
$ldap->create_missing_trees($fai); try {
if (!$ldap->success()) { $ldap->create_missing_trees($fai);
msg_dialog::display(_('LDAP error'), msgPool::ldaperror($ldap->get_error(), $fai, LDAP_ADD, get_class()), LDAP_ERROR); } catch (FusionDirectoryError $error) {
$error->display();
return; return;
} }
} }
...@@ -252,9 +253,10 @@ class serviceRepository extends simpleService ...@@ -252,9 +253,10 @@ class serviceRepository extends simpleService
// Add classes OUs // Add classes OUs
foreach (['Script', 'Hook', 'Template', 'Variable', 'Profile', 'Package', 'Partition'] as $type) { foreach (['Script', 'Hook', 'Template', 'Variable', 'Profile', 'Package', 'Partition'] as $type) {
$ldap->cd($dn); $ldap->cd($dn);
$ldap->create_missing_trees(get_ou('fai'.$type.'RDN').$dn); try {
if (!$ldap->success()) { $ldap->create_missing_trees(get_ou('fai'.$type.'RDN').$dn);
msg_dialog::display(_('LDAP error'), msgPool::ldaperror($ldap->get_error(), get_ou('fai'.$type.'RDN').$dn, LDAP_ADD, get_class()), LDAP_ERROR); } catch (FusionDirectoryError $error) {
$error->display();
} }
} }
} else { } else {
......
...@@ -114,7 +114,11 @@ if (preg_match('/QUERY>PROLOG<\/QUERY/', $xml)) { ...@@ -114,7 +114,11 @@ if (preg_match('/QUERY>PROLOG<\/QUERY/', $xml)) {
} else { } else {
/* Make sure branch is existing */ /* Make sure branch is existing */
$ldap->cd($config->current['BASE']); $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 */ /* Create root node */
$ldap->cd($dn); $ldap->cd($dn);
......
...@@ -95,15 +95,10 @@ class pgpServerInfo extends simplePlugin ...@@ -95,15 +95,10 @@ class pgpServerInfo extends simplePlugin
if (!$ldap->count()) { if (!$ldap->count()) {
@DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->pgpBaseKeySpaceDN, "Creating branch"); @DEBUG(DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $this->pgpBaseKeySpaceDN, "Creating branch");
$ldap->cd($config->current['BASE']); $ldap->cd($config->current['BASE']);
$ldap->create_missing_trees($this->pgpBaseKeySpaceDN); try {
if (!$ldap->success()) { $ldap->create_missing_trees($this->pgpBaseKeySpaceDN);
$errors[] = new SimplePluginLdapError( } catch (FusionDirectoryError $error) {
$this, $errors[] = SimplePluginError::relocate($this, $error);
$this->pgpBaseKeySpaceDN,
LDAP_ADD,
$ldap->get_error(),
$ldap->get_errno()
);
} }
} }
/* Delete the old branch if empty */ /* Delete the old branch if empty */
......
...@@ -203,7 +203,11 @@ class userReminderConfig extends simplePlugin ...@@ -203,7 +203,11 @@ class userReminderConfig extends simplePlugin
global $config; global $config;
$ldap = $config->get_ldap_link(); $ldap = $config->get_ldap_link();
$ldap->cd($config->current['BASE']); $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(); parent::post_save();
} }
} }
Supports Markdown
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