A free open source IT asset/license management system
Add version checking to LDAP troubleshooter, clean up ldap model
Brady Wetherington15e64155b5da
diff --git a/app/Console/Commands/LdapTroubleshooter.php b/app/Console/Commands/LdapTroubleshooter.phpindex a378428df5..24c61dc408 100644--- a/app/Console/Commands/LdapTroubleshooter.php+++ b/app/Console/Commands/LdapTroubleshooter.php@@ -172,6 +172,23 @@ class LdapTroubleshooter extends Command$this->line(implode(" \\\n",$output));exit(0);}++ //PHP Version check for warning+ $php_version = phpversion();+ list($major, $minor, $patch) = explode('.', $php_version);+ if (+ $major < 8 ||+ ($major == 8 && $minor < 3) ||+ ($major == 8 && $minor == 3 && $patch < 21) ||+ ($major == 8 && $minor == 4 && $patch < 7)+ ) {+ $this->warn("PHP Version: $php_version WARNING - Versions before 8.3.21 or 8.4.7 will return INCONSISTENT results!");+ if (!$this->confirm("Are you sure you wish to continue?")) {+ $this->warn("ABORTING");+ exit(-1);+ }+ }+if(!$this->option('force')) {$confirmation = $this->confirm('WARNING: This command will make several attempts to connect to your LDAP server. Are you sure this is ok?');if(!$confirmation) {diff --git a/app/Models/Ldap.php b/app/Models/Ldap.phpindex b2d1dbea79..c2af1111c0 100644--- a/app/Models/Ldap.php+++ b/app/Models/Ldap.php@@ -34,18 +34,11 @@ class Ldap extends Modelif ($ignore_cert) {\Log::debug("IGNORING certs");if (ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER)) {- $value = 0;- $results = ldap_set_option(null, 0x66f, $value); //- \Log::error("RESULT OF WEIRD SET OPTION(disabling certs): " . $results);-return true;}} else {\Log::debug("ENABLING certs");if (ldap_set_option(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_DEMAND)) {- $results = ldap_set_option(null, 0x66f, 0); //- \Log::error("RESULT OF WEIRD SET OPTION(enabling certs): " . $results);-return true;}}@@ -80,7 +73,6 @@ class Ldap extends Modelif (env('LDAPTLS_CACERT')) {putenv('LDAPTLS_CACERT='.env('LDAPTLS_CACERT'));}-// work around bug *HERE* maybe?$connection = @ldap_connect($ldap_host);if (! $connection) {