diff --git a/include/class_config.inc b/include/class_config.inc
index 9318e13cbcb193602f2b2cbcb41586ee77cc3827..2b1bedbc6337dcb1b98fdcf4484298f404365f86 100644
--- a/include/class_config.inc
+++ b/include/class_config.inc
@@ -308,7 +308,7 @@ class config
   {
     global $ui;
 
-    if ($this->ldapLink === NULL || !is_resource($this->ldapLink->cid)) {
+    if (($this->ldapLink === NULL) || ($this->ldapLink->cid === FALSE)) {
       /* Build new connection */
       $this->ldapLink = LDAP::init($this->current['SERVER'], $this->current['BASE'],
           $this->current['ADMINDN'], $this->get_credentials($this->current['ADMINPASSWORD']));
diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index a1fbdfdaaca3d8fb435e8d79bba8a92a02f14439..6b185290c30e5f1311af30124874922a06ba5d22 100644
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
@@ -37,8 +37,12 @@ class LDAP
   var $reconnect      = FALSE;
   var $tls            = FALSE;
 
-  /* connection identifier */
-  var $cid;
+  /**
+   * Connection identifier
+   *
+   * @var resource|object|false
+   */
+  var $cid            = FALSE;
 
   var $hasres         = [];
   var $sr             = [];
@@ -294,7 +298,7 @@ class LDAP
   function unbind ()
   {
     @ldap_unbind($this->cid);
-    $this->cid = NULL;
+    $this->cid = FALSE;
     logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, '', 'unbind');
   }
 
@@ -769,9 +773,8 @@ class LDAP
       $r = ldap_rename($this->cid, $source, $dest_rdn, $parent, TRUE);
       $this->error = ldap_error($this->cid);
 
-      /* Check if destination dn exists, if not the
-          server may not support this operation */
-      $r &= is_resource($this->dn_exists($dest));
+      /* Check if destination dn exists, if not the server may not support this operation */
+      $r &= $this->dn_exists($dest);
       logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, $this->error, 'rename("'.$source.'","'.$dest.'")');
       return $r;
     } else {
@@ -1202,7 +1205,7 @@ class LDAP
 
     // Try to open the process
     $process = proc_open($cmd, $descriptorspec, $pipes);
-    if (is_resource($process)) {
+    if ($process !== FALSE) {
       // Write the password to stdin
       fclose($pipes[0]);
 
@@ -1221,10 +1224,10 @@ class LDAP
     return $res;
   }
 
-  function dn_exists ($dn)
+  function dn_exists ($dn): bool
   {
     logging::debug(DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__, '', 'dn_exists('.$dn.')');
-    return @ldap_read($this->cid, $dn, "(objectClass=*)", ["objectClass"]);
+    return (@ldap_read($this->cid, $dn, '(objectClass=*)', ['objectClass']) !== FALSE);
   }
 
   function parseLdif (string $str_attr): array