Changed LDAP 600 to 500, clearer error messages on LDAP test

This commit is contained in:
snipe 2020-04-09 09:55:44 -07:00
parent 83ee64f155
commit f8a72db696
No known key found for this signature in database
GPG key ID: 10BFFDA3ED34B5AC

View file

@ -20,8 +20,8 @@ class SettingsController extends Controller
{ {
if (Setting::getSettings()->ldap_enabled!='1') { if (Setting::getSettings()->ldap_enabled!='1') {
\Log::debug('LDAP is not enabled cannot test.'); \Log::debug('LDAP is not enabled so cannot test.');
return response()->json(['message' => 'LDAP is not enabled, cannot test.'], 400); return response()->json(['message' => 'LDAP is not enabled, so we cannot test LDAP connections.'], 400);
} }
\Log::debug('Preparing to test LDAP connection'); \Log::debug('Preparing to test LDAP connection');
@ -33,13 +33,13 @@ class SettingsController extends Controller
Ldap::bindAdminToLdap($connection); Ldap::bindAdminToLdap($connection);
return response()->json(['message' => 'It worked!'], 200); return response()->json(['message' => 'It worked!'], 200);
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug('Bind failed'); \Log::debug('LDAP connected but Bind failed. Please check your LDAP settings and try again.');
return response()->json(['message' => $e->getMessage()], 400); return response()->json(['message' => $e->getMessage()], 400);
//return response()->json(['message' => $e->getMessage()], 500); //return response()->json(['message' => $e->getMessage()], 500);
} }
} catch (\Exception $e) { } catch (\Exception $e) {
\Log::debug('Connection failed but we cannot debug it any further on our end.'); \Log::info('LDAP connection failed but we cannot debug it any further on our end.');
return response()->json(['message' => $e->getMessage()], 600); return response()->json(['message' => 'The LDAP connection failed but we cannot debug it any further on our end. The error from the server is: '.$e->getMessage()], 500);
} }