From e7038cfdc87cd47b9491f670caf2fb70feca87da Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 13 Jul 2016 05:50:40 -0700 Subject: [PATCH] LDAP tester --- app/Http/Controllers/SettingsController.php | 20 ++++++++++++++++++++ app/Http/routes.php | 13 +++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 09127e6e6d..e93d77c0ff 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use Input; use Lang; use App\Models\Setting; +use App\Models\Ldap; use Redirect; use DB; use Str; @@ -428,6 +429,25 @@ class SettingsController extends Controller } + public function getLdapTest() { + + try { + $connection = Ldap::connectToLdap(); + try { + Ldap::bindAdminToLdap($connection); + return response()->json(['message' => 'It worked!'], 200); + } catch (\Exception $e) { + return response()->json(['message' => $e->getMessage()], 500); + } + return response()->json(['message' => 'It worked!'], 200); + } catch (\Exception $e) { + return response()->json(['message' => $e->getMessage()], 500); + } + + + } + + /** * Show the listing of backups * diff --git a/app/Http/routes.php b/app/Http/routes.php index a61b8573e7..f0ac9f2267 100755 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -466,12 +466,19 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth']], function () Route::group([ 'prefix' => 'app' ], function () { Route::post('purge', ['as' => 'purge', 'uses' => 'SettingsController@postPurge']); - - Route::get('/', [ 'as' => 'app', 'uses' => 'SettingsController@getIndex' ]); Route::get('edit', [ 'as' => 'edit/settings', 'uses' => 'SettingsController@getEdit' ]); Route::post('edit', 'SettingsController@postEdit'); + + Route::get('ldaptest', [ + 'as' => 'settings/ldaptest', + 'uses' => 'SettingsController@getLdapTest' + ]); + + Route::get('/', [ 'as' => 'app', 'uses' => 'SettingsController@getIndex' ]); }); + + # Settings Route::group([ 'prefix' => 'backups', 'middleware' => 'auth' ], function () { @@ -488,6 +495,8 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth']], function () 'as' => 'settings/backups', 'uses' => 'SettingsController@postBackups' ]); + + Route::get('/', [ 'as' => 'settings/backups', 'uses' => 'SettingsController@getBackups' ]); });