Skip to content
Snippets Groups Projects
Commit 936ba773 authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Capture some more errors than before...

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1230 44740490-163a-0410-bde0-09ae8108e29a
parent e111c784
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,31 @@ if (!$session->isValid('login-admin') ) { ...@@ -11,6 +11,31 @@ if (!$session->isValid('login-admin') ) {
} }
function myErrorHandler($errno, $errstr, $errfile, $errline) {
switch ($errno) {
case E_USER_ERROR:
SimpleSAML_Logger::error('PHP_ERROR : [' . $errno . '] ' . $errstr . '. Fatal error on line ' . $errline . ' in file ' . $errfile);
break;
case E_USER_WARNING:
SimpleSAML_Logger::error('PHP_WARNING : [' . $errno . '] ' . $errstr . '. Warning on line ' . $errline . ' in file ' . $errfile);
break;
case E_USER_NOTICE:
SimpleSAML_Logger::error('PHP_WARNING : [' . $errno . '] ' . $errstr . '. Warning on line ' . $errline . ' in file ' . $errfile);
break;
default:
SimpleSAML_Logger::error('PHP_UNKNOWN : [' . $errno . '] ' . $errstr . '. Unknown error on line ' . $errline . ' in file ' . $errfile);
break;
}
/* Don't execute PHP internal error handler */
return true;
}
$old_error_handler = set_error_handler("myErrorHandler");
$ldapconfig = $config->copyFromBase('loginfeide', 'config-login-feide.php'); $ldapconfig = $config->copyFromBase('loginfeide', 'config-login-feide.php');
$ldapStatusConfig = $config->copyFromBase('ldapstatus', 'module_ldapstatus.php'); $ldapStatusConfig = $config->copyFromBase('ldapstatus', 'module_ldapstatus.php');
...@@ -126,8 +151,10 @@ foreach ($orgs AS $orgkey => $orgconfig) { ...@@ -126,8 +151,10 @@ foreach ($orgs AS $orgkey => $orgconfig) {
// LDAP Connect // LDAP Connect
try { try {
$ldap = new SimpleSAML_Auth_LDAP($orgconfig['hostname'], (array_key_exists('enable_tls', $orgconfig) ? $orgconfig['enable_tls'] : FALSE), $debug); $ldap = new SimpleSAML_Auth_LDAP($orgconfig['hostname'], (array_key_exists('enable_tls', $orgconfig) ? $orgconfig['enable_tls'] : FALSE), $debug);
if ($ldap->getLastError()) throw new Exception('LDAP warning: ' . $ldap->getLastError());
$results[$orgkey]['connect'] = array(TRUE,NULL); $results[$orgkey]['connect'] = array(TRUE,NULL);
} catch (Exception $e) { } catch (Exception $e) {
SimpleSAML_Logger::debug('ldapstatus: Connect error() [' .$orgkey . ']: ' . $e->getMessage());
$results[$orgkey]['connect'] = array(FALSE,$e->getMessage()); $results[$orgkey]['connect'] = array(FALSE,$e->getMessage());
$results[$orgkey]['time'] = microtime(TRUE) - $previous; $results[$orgkey]['time'] = microtime(TRUE) - $previous;
continue; continue;
...@@ -136,7 +163,9 @@ foreach ($orgs AS $orgkey => $orgconfig) { ...@@ -136,7 +163,9 @@ foreach ($orgs AS $orgkey => $orgconfig) {
// Bind as admin user // Bind as admin user
if (isset($orgconfig['adminUser'])) { if (isset($orgconfig['adminUser'])) {
try { try {
SimpleSAML_Logger::debug('ldapstatus: Admin bind() [' .$orgkey . ']');
$success = $ldap->bind($orgconfig['adminUser'], $orgconfig['adminPassword']); $success = $ldap->bind($orgconfig['adminUser'], $orgconfig['adminPassword']);
if ($ldap->getLastError()) throw new Exception('LDAP warning: ' . $ldap->getLastError());
if ($success) { if ($success) {
$results[$orgkey]['adminBind'] = array(TRUE,NULL); $results[$orgkey]['adminBind'] = array(TRUE,NULL);
} else { } else {
...@@ -154,6 +183,7 @@ foreach ($orgs AS $orgkey => $orgconfig) { ...@@ -154,6 +183,7 @@ foreach ($orgs AS $orgkey => $orgconfig) {
// Search for bogus user // Search for bogus user
try { try {
$dn = $ldap->searchfordn($orgconfig['searchbase'], 'eduPersonPrincipalName', $eppn, TRUE); $dn = $ldap->searchfordn($orgconfig['searchbase'], 'eduPersonPrincipalName', $eppn, TRUE);
if ($ldap->getLastError()) throw new Exception('LDAP warning: ' . $ldap->getLastError());
$results[$orgkey]['ldapSearchBogus'] = array(TRUE,NULL); $results[$orgkey]['ldapSearchBogus'] = array(TRUE,NULL);
} catch (Exception $e) { } catch (Exception $e) {
$results[$orgkey]['ldapSearchBogus'] = array(FALSE,$e->getMessage()); $results[$orgkey]['ldapSearchBogus'] = array(FALSE,$e->getMessage());
...@@ -168,6 +198,7 @@ foreach ($orgs AS $orgkey => $orgconfig) { ...@@ -168,6 +198,7 @@ foreach ($orgs AS $orgkey => $orgconfig) {
// Try to search for DN of test account // Try to search for DN of test account
try { try {
$dn = $ldap->searchfordn($orgconfig['searchbase'], 'eduPersonPrincipalName', $orgconfig['testUser']); $dn = $ldap->searchfordn($orgconfig['searchbase'], 'eduPersonPrincipalName', $orgconfig['testUser']);
if ($ldap->getLastError()) throw new Exception('LDAP warning: ' . $ldap->getLastError());
$results[$orgkey]['ldapSearchTestUser'] = array(TRUE,NULL); $results[$orgkey]['ldapSearchTestUser'] = array(TRUE,NULL);
} catch (Exception $e) { } catch (Exception $e) {
$results[$orgkey]['ldapSearchTestUser'] = array(FALSE,$e->getMessage()); $results[$orgkey]['ldapSearchTestUser'] = array(FALSE,$e->getMessage());
...@@ -186,6 +217,7 @@ foreach ($orgs AS $orgkey => $orgconfig) { ...@@ -186,6 +217,7 @@ foreach ($orgs AS $orgkey => $orgconfig) {
try { try {
$attributes = $ldap->getAttributes($dn, $orgconfig['attributes'], $ldapconfig->getValue('attributesize.max', NULL)); $attributes = $ldap->getAttributes($dn, $orgconfig['attributes'], $ldapconfig->getValue('attributesize.max', NULL));
if ($ldap->getLastError()) throw new Exception('LDAP warning: ' . $ldap->getLastError());
$results[$orgkey]['ldapGetAttributesTestUser'] = array(TRUE,NULL); $results[$orgkey]['ldapGetAttributesTestUser'] = array(TRUE,NULL);
} catch(Exception $e) { } catch(Exception $e) {
$results[$orgkey]['ldapGetAttributesTestUser'] = array(FALSE,$e->getMessage()); $results[$orgkey]['ldapGetAttributesTestUser'] = array(FALSE,$e->getMessage());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment