Quellcode durchsuchen

More work on LDAP
Added new account suffix
Fix help tooltips without id's
Add new account DN preview

causefx vor 7 Jahren
Ursprung
Commit
8c72b398af

+ 1 - 0
api/config/default.php

@@ -5,6 +5,7 @@ return array(
 	'authBackend' => '',
 	'authBackendHost' => '',
 	'authBackendHostPrefix' => '',
+	'authBackendHostSuffix' => '',
 	'ldapBindUsername' => '',
 	'ldapBindPassword' => '',
 	'authBaseDN' => '',

+ 5 - 4
api/functions/auth-functions.php

@@ -206,6 +206,7 @@ if (function_exists('ldap_connect')) {
 				$port = (isset($digest['port']) ? $digest['port'] : (strtolower($scheme) == 'ldap' ? 389 : 636));
 				// Reassign
 				$ldapHosts[] = $host;
+				$ldapServersNew[$key] = $scheme . '://' . $host . ':' . $port; // May use this later
 				if ($i == 0) {
 					$ldapPort = $port;
 				}
@@ -219,8 +220,8 @@ if (function_exists('ldap_connect')) {
 				'password' => (empty($GLOBALS['ldapBindPassword'])) ? null : decrypt($GLOBALS['ldapBindPassword']),
 				// Optional Configuration Options
 				'schema' => (($GLOBALS['ldapType'] == '1') ? Adldap\Schemas\ActiveDirectory::class : (($GLOBALS['ldapType'] == '2') ? Adldap\Schemas\OpenLDAP::class : Adldap\Schemas\FreeIPA::class)),
-				'account_prefix' => '',
-				'account_suffix' => '',
+				'account_prefix' => (empty($GLOBALS['authBackendHostPrefix'])) ? null : $GLOBALS['authBackendHostPrefix'],
+				'account_suffix' => (empty($GLOBALS['authBackendHostSuffix'])) ? null : $GLOBALS['authBackendHostSuffix'],
 				'port' => $ldapPort,
 				'follow_referrals' => false,
 				'use_ssl' => false,
@@ -238,7 +239,8 @@ if (function_exists('ldap_connect')) {
 			try {
 				// If a successful connection is made to your server, the provider will be returned.
 				$provider = $ad->connect();
-				if ($provider->auth()->attempt(checkHostPrefix($GLOBALS['authBackendHostPrefix']) . $username, $password)) {
+				//prettyPrint($provider);
+				if ($provider->auth()->attempt($username, $password)) {
 					// Passed.
 					return true;
 				} else {
@@ -255,7 +257,6 @@ if (function_exists('ldap_connect')) {
 				writeLog('error', 'LDAP Function - Error: ' . $e->getMessage(), $username);
 				// The user didn't supply a password.
 			}
-			return ($bind) ? true : false;
 		}
 		return false;
 	}

+ 21 - 3
api/functions/organizr-functions.php

@@ -445,6 +445,7 @@ function getSettingsMain()
 			),
 			array(
 				'type' => 'button',
+				'name' => 'force-install-branch',
 				'label' => 'Force Install Branch',
 				'class' => 'updateNow',
 				'icon' => 'fa fa-download',
@@ -572,9 +573,19 @@ function getSettingsMain()
 				'type' => 'input',
 				'name' => 'authBackendHostPrefix',
 				'class' => 'ldapAuth switchAuth',
-				'label' => 'Host Prefix',
+				'label' => 'Account Prefix',
+				'id' => 'authBackendHostPrefix-input',
 				'value' => $GLOBALS['authBackendHostPrefix'],
-				'placeholder' => 'Domain prefix - i.e. Controller from Controller\Username'
+				'placeholder' => 'Account prefix - i.e. Controller\ from Controller\Username for AD - uid= for OpenLDAP'
+			),
+			array(
+				'type' => 'input',
+				'name' => 'authBackendHostSuffix',
+				'class' => 'ldapAuth switchAuth',
+				'label' => 'Account Suffix',
+				'id' => 'authBackendHostSuffix-input',
+				'value' => $GLOBALS['authBackendHostSuffix'],
+				'placeholder' => 'Account suffix - start with comma - ,ou=people,dc=domain,dc=tld'
 			),
 			array(
 				'type' => 'input',
@@ -591,13 +602,20 @@ function getSettingsMain()
 				'label' => 'Password',
 				'value' => $GLOBALS['ldapBindPassword']
 			),
+			array(
+				'type' => 'html',
+				'label' => 'Account DN',
+				'html' => '<span id="accountDN">' . $GLOBALS['authBackendHostPrefix'] . 'TestAcct' . $GLOBALS['authBackendHostSuffix'] . '</span>'
+			),
 			array(
 				'type' => 'button',
+				'name' => 'test-button-ldap',
 				'label' => 'Test Connection',
 				'icon' => 'fa fa-flask',
 				'class' => 'ldapAuth switchAuth',
 				'text' => 'Test Connection',
-				'attr' => 'onclick="testAPIConnection(\'ldap\')"'
+				'attr' => 'onclick="testAPIConnection(\'ldap\')"',
+				'help' => 'Remember! Please save before using the test button!'
 			),
 			array(
 				'type' => 'input',

+ 5 - 0
js/custom.js

@@ -1865,4 +1865,9 @@ $(document).on('click', ".close-popup", function(){
 $(document).on('click', ".copyDebug", function(){
     copyDebug();
     $('#internal-clipboard').trigger('click');
+});
+// AccountDN change
+$(document).on("keyup", "#authBackendHostPrefix-input, #authBackendHostSuffix-input", function () {
+    var newDN = $('#authBackendHostPrefix-input').val() + 'TestAcct' + $('#authBackendHostSuffix-input').val();
+    $('#accountDN').html(newDN);
 });

Datei-Diff unterdrückt, da er zu groß ist
+ 0 - 0
js/custom.min.js


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.