From 10734aa4a481ca7f9281b65386efb2aa2ef4d8c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Tue, 20 Jan 2009 10:41:12 +0000 Subject: [PATCH] bugfix for ldap status page with admin and test user access git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1179 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Auth/LDAP.php | 1 + modules/ldapstatus/www/index.php | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/SimpleSAML/Auth/LDAP.php b/lib/SimpleSAML/Auth/LDAP.php index de672a4dd..fb9fb4008 100644 --- a/lib/SimpleSAML/Auth/LDAP.php +++ b/lib/SimpleSAML/Auth/LDAP.php @@ -23,6 +23,7 @@ class SimpleSAML_Auth_LDAP { SimpleSAML_Logger::debug('Library - LDAP __construct(): Setup LDAP with host [' . $hostname . '] and tls [' . var_export($enable_tls, true) . ']'); + ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7); $this->ldap = @ldap_connect($hostname); # ldap_set_option($this->ldap, LDAP_OPT_NETWORK_TIMEOUT, 2); ldap_set_option($this->ldap, LDAP_OPT_TIMELIMIT, 2); diff --git a/modules/ldapstatus/www/index.php b/modules/ldapstatus/www/index.php index 4bea0d1d2..4f1523391 100644 --- a/modules/ldapstatus/www/index.php +++ b/modules/ldapstatus/www/index.php @@ -88,7 +88,7 @@ foreach ($orgs AS $orgkey => $orgconfig) { // LDAP Connect try { - $ldap = new SimpleSAML_Auth_LDAP($orgconfig['hostname'], $orgconfig['enable_tls']); + $ldap = new SimpleSAML_Auth_LDAP($orgconfig['hostname'], (array_key_exists('enable_tls', $orgconfig) ? $orgconfig['enable_tls'] : FALSE)); $results[$orgkey]['connect'] = array(TRUE,NULL); } catch (Exception $e) { $results[$orgkey]['connect'] = array(FALSE,$e->getMessage()); @@ -98,8 +98,12 @@ foreach ($orgs AS $orgkey => $orgconfig) { // Bind as admin user if (isset($orgconfig['adminUser'])) { try { - $ldap->bind($orgconfig['adminUser'], $orgconfig['adminPassword']); - $results[$orgkey]['adminBind'] = array(TRUE,NULL); + $success = $ldap->bind($orgconfig['adminUser'], $orgconfig['adminPassword']); + if ($success) { + $results[$orgkey]['adminBind'] = array(TRUE,NULL); + } else { + $results[$orgkey]['adminBind'] = array(FALSE,'Could not bind()' ); + } } catch (Exception $e) { $results[$orgkey]['adminBind'] = array(FALSE,$e->getMessage()); continue; @@ -107,7 +111,7 @@ foreach ($orgs AS $orgkey => $orgconfig) { } - $eppn = 'test@feide.no'; + $eppn = 'asdasdasdasd@feide.no'; // Search for bogus user try { $dn = $ldap->searchfordn($orgconfig['searchbase'], 'eduPersonPrincipalName', $eppn, TRUE); @@ -123,7 +127,7 @@ foreach ($orgs AS $orgkey => $orgconfig) { // Try to search for DN of test account try { - $dn = $ldap->searchfordn($orgconfig['searchbase'], 'eduPersonPrincipalName', $eppn); + $dn = $ldap->searchfordn($orgconfig['searchbase'], 'eduPersonPrincipalName', $orgconfig['testUser']); $results[$orgkey]['ldapSearchTestUser'] = array(TRUE,NULL); } catch (Exception $e) { $results[$orgkey]['ldapSearchTestUser'] = array(FALSE,$e->getMessage()); -- GitLab