From 69511f860bc0624aab79f16ff85212487ac7e53d Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <machniak@kolabsys.com>
Date: Wed, 31 May 2023 13:13:47 +0200
Subject: [PATCH] Code cleanup

---
 lib/Net/LDAP3.php | 53 +++++++++++++++++------------------------------
 1 file changed, 19 insertions(+), 34 deletions(-)

diff --git a/lib/Net/LDAP3.php b/lib/Net/LDAP3.php
index abfea8f..d4c88ce 100644
--- a/lib/Net/LDAP3.php
+++ b/lib/Net/LDAP3.php
@@ -785,39 +785,24 @@ class Net_LDAP3
         }
 
         $output = array();
+        $command = array(
+            $moz_ldapsearch,
+            '-x',
+            '-h',
+            preg_replace('|^[a-z]+://|i', '', $this->_current_host),
+            '-b',
+            escapeshellarg($entry_dn),
+            '-s',
+            'base',
+            '-D',
+            escapeshellarg($this->_current_bind_dn),
+            '-w',
+            escapeshellarg($this->_current_bind_pw)
+        );
 
-        if ($moz_ldapsearch == "/usr/bin/ldapsearch") {
-            $command = Array(
-                    $moz_ldapsearch,
-                    '-x',
-                    '-h',
-                    preg_replace('|^[a-z]+://|i', '', $this->_current_host),
-                    '-b',
-                    escapeshellarg($entry_dn),
-                    '-s',
-                    'base',
-                    '-D',
-                    escapeshellarg($this->_current_bind_dn),
-                    '-w',
-                    escapeshellarg($this->_current_bind_pw)
-                );
-        } else {
-            $command = Array(
-                    $moz_ldapsearch,
-                    '-x',
-                    '-h',
-                    preg_replace('|^[a-z]+://|i', '', $this->_current_host),
-                    '-p',
-                    $this->config_get('port', 389),
-                    '-b',
-                    escapeshellarg($entry_dn),
-                    '-s',
-                    'base',
-                    '-D',
-                    escapeshellarg($this->_current_bind_dn),
-                    '-w',
-                    escapeshellarg($this->_current_bind_pw)
-                );
+        if ($moz_ldapsearch != "/usr/bin/ldapsearch") {
+            $command[] = '-p';
+            $command[] = $this->config_get('port', 389);
         }
 
         if ($this->vendor_name() == "Oracle Corporation") {
@@ -2496,7 +2481,7 @@ class Net_LDAP3
 
         switch ($_acl_components[1]) {
             case "entryLevel":
-                $attributes['entrylevelrights'] = Array();
+                $attributes['entrylevelrights'] = array();
                 $_acl_value = explode(',', $_acl_value);
 
                 foreach ($_acl_value as $right) {
@@ -2509,7 +2494,7 @@ class Net_LDAP3
                 break;
 
             case "attributeLevel":
-                $attributes['attributelevelrights'][$_acl_components[2]] = Array();
+                $attributes['attributelevelrights'][$_acl_components[2]] = array();
                 $_acl_value = explode(',', $_acl_value);
 
                 foreach ($_acl_value as $right) {
-- 
GitLab