diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index c8c7303d2d28073e14547e92f383d1f5f0d65aee..be0a4988f6b68b441fe0a9be3329689b541b40fe 100644
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
@@ -911,11 +911,8 @@ class LDAP
         }
       }
 
-      $this->cat($srp, $cdn);
-      $attrs = $this->fetch($srp);
-
       /* Create missing entry? */
-      if (!count($attrs)) {
+      if (!$this->dn_exists($cdn)) {
         $type   = preg_replace('/^([^=]+)=.*$/', '\\1', $cdn);
         $param  = preg_replace('/^[^=]+=([^,]+).*$/', '\\1', $cdn);
         $param  = preg_replace(['/\\\\,/','/\\\\"/'], [',','"'], $param);
diff --git a/include/functions.inc b/include/functions.inc
index 0ff4d6611408d2cbd76387ca7e66def3a8521a3c..7adf0d993883703ee4f7ddf6721fbcd116b4452e 100644
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -1699,7 +1699,7 @@ function change_password ($dn, $password, $hash = "")
  *
  * \return either the result or "" in any other case
  */
-function getEntryCSN ($dn)
+function getEntryCSN (string $dn): string
 {
   global $config;
   if (empty($dn) || !is_object($config)) {
@@ -1711,9 +1711,9 @@ function getEntryCSN ($dn)
   if ($attr != '') {
     $ldap = $config->get_ldap_link();
     $ldap->cat($dn, [$attr]);
-    $csn = $ldap->fetch();
-    if (isset($csn[$attr][0])) {
-      return $csn[$attr][0];
+    $attrs = $ldap->fetch();
+    if (isset($attrs[$attr][0])) {
+      return $attrs[$attr][0];
     }
   }
   return '';
diff --git a/include/simpleplugin/class_simplePlugin.inc b/include/simpleplugin/class_simplePlugin.inc
index 4eef41ff4312749e7fcd964084f7d8d1d455bb60..7cf1d579fe72b2d5476fc2366c15d62dace06b9c 100644
--- a/include/simpleplugin/class_simplePlugin.inc
+++ b/include/simpleplugin/class_simplePlugin.inc
@@ -239,6 +239,7 @@ class simplePlugin implements SimpleTab
           throw new NonExistingLdapNodeException('Could not open dn '.$this->dn);
         }
         if ($this->mainTab) {
+          $this->entryCSN = getEntryCSN($this->dn);
           /* Make sure that initially_was_account is TRUE if we loaded an LDAP node,
            *  even if it’s missing an objectClass */
           $this->is_account = TRUE;
@@ -290,7 +291,6 @@ class simplePlugin implements SimpleTab
 
     if ($this->mainTab) {
       $this->is_account = TRUE;
-      $this->entryCSN = getEntryCSN($this->dn);
     }
 
     if (!isset($this->templatePath)) {
@@ -1295,35 +1295,37 @@ class simplePlugin implements SimpleTab
     return array_merge_unique($oc, $this->objectclasses);
   }
 
+  /* \!brief Prepare $this->attrs */
   protected function prepare_save (): array
   {
     global $config;
-    /* prepare $this->attrs */
-    $ldap = $config->get_ldap_link();
 
     $this->entryCSN = '';
 
     /* Start with empty array */
-    $this->attrs = [];
+    $this->attrs  = [];
+    $oc           = [];
 
-    /* Get current objectClasses in order to add the required ones */
-    $ldap->cat($this->dn, ['fdTemplateField', 'objectClass']);
+    if (!$this->mainTab || $this->initially_was_account) {
+      /* Get current objectClasses in order to add the required ones */
+      $ldap = $config->get_ldap_link();
+      $ldap->cat($this->dn, ['fdTemplateField', 'objectClass']);
 
-    $tmp  = $ldap->fetch();
-    $oc   = [];
+      $tmp  = $ldap->fetch();
 
-    if ($this->is_template) {
-      if (isset($tmp['fdTemplateField'])) {
-        foreach ($tmp['fdTemplateField'] as $tpl_field) {
-          if (preg_match('/^objectClass:(.+)$/', $tpl_field, $m)) {
-            $oc[] = $m[1];
+      if ($this->is_template) {
+        if (isset($tmp['fdTemplateField'])) {
+          foreach ($tmp['fdTemplateField'] as $tpl_field) {
+            if (preg_match('/^objectClass:(.+)$/', $tpl_field, $m)) {
+              $oc[] = $m[1];
+            }
           }
         }
-      }
-    } else {
-      if (isset($tmp['objectClass'])) {
-        $oc = $tmp['objectClass'];
-        unset($oc['count']);
+      } else {
+        if (isset($tmp['objectClass'])) {
+          $oc = $tmp['objectClass'];
+          unset($oc['count']);
+        }
       }
     }
 
@@ -1361,19 +1363,18 @@ class simplePlugin implements SimpleTab
 
     /* Check if this is a new entry ... add/modify */
     $ldap = $config->get_ldap_link();
-    $ldap->cat($this->dn, ["objectClass"]);
     if ($this->mainTab && !$this->initially_was_account) {
-      if ($ldap->count()) {
+      if ($ldap->dn_exists($this->dn)) {
         return [sprintf(_('There is already an entry with the same dn : %s'), $this->dn)];
       }
       $ldap->cd($config->current['BASE']);
       $ldap->create_missing_trees(preg_replace('/^[^,]+,/', '', $this->dn));
-      $action = "add";
+      $action = 'add';
     } else {
-      if (!$ldap->count()) {
+      if (!$ldap->dn_exists($this->dn)) {
         return [sprintf(_('The entry %s is not existing'), $this->dn)];
       }
-      $action = "modify";
+      $action = 'modify';
     }
 
     $ldap->cd($this->dn);