From 1426d4e3e8a8d81b6e0ee46c3e63aeb47bf22722 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Fri, 10 Jul 2009 07:35:43 +0000
Subject: [PATCH] Check schema version on LDAP in ldapstatus

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1556 44740490-163a-0410-bde0-09ae8108e29a
---
 .../lib/Auth/Backend/Test/StandardLDAPTest.php       | 12 ++++++++++++
 modules/ldapstatus/templates/ldapsinglehost.php      |  1 +
 modules/ldapstatus/templates/ldapstatus.php          |  2 ++
 3 files changed, 15 insertions(+)

diff --git a/modules/ldapstatus/lib/Auth/Backend/Test/StandardLDAPTest.php b/modules/ldapstatus/lib/Auth/Backend/Test/StandardLDAPTest.php
index 56b524365..fa07180bf 100755
--- a/modules/ldapstatus/lib/Auth/Backend/Test/StandardLDAPTest.php
+++ b/modules/ldapstatus/lib/Auth/Backend/Test/StandardLDAPTest.php
@@ -238,6 +238,18 @@ class sspmod_ldapstatus_Auth_Backend_Test_StandardLDAPTest extends sspmod_feide_
 
 				$result['getTestOrg'] = array(TRUE,$tester->tack('getTestOrg'));
 				$result['getTestOrg']['time'] = $tester->tack('getTestOrg', FALSE); 
+				
+				if (array_key_exists('eduPersonOrgDN:norEduOrgSchemaVersion', $attributes)) {
+					if ($attributes['eduPersonOrgDN:norEduOrgSchemaVersion'][0] == '1.4') {
+						$result['schema'] = array(TRUE, 'Version: ' . $attributes['eduPersonOrgDN:norEduOrgSchemaVersion'][0]);
+					} else {
+						$result['schema'] = array(FALSE, 'Version: ' . $attributes['eduPersonOrgDN:norEduOrgSchemaVersion'][0]);
+					}
+				} 
+				
+				$result['getTestOrg'] = array(TRUE,$tester->tack('getTestOrg'));
+				$result['getTestOrg']['time'] = $tester->tack('getTestOrg', FALSE);
+				
 			} catch(Exception $e) {
 				$tester->log('LDAP Test user attributes failed: ' . $e->getMessage());
 				$result['getTestOrg'] = array(FALSE,$e->getMessage());
diff --git a/modules/ldapstatus/templates/ldapsinglehost.php b/modules/ldapstatus/templates/ldapsinglehost.php
index e1785a3aa..4daff86de 100644
--- a/modules/ldapstatus/templates/ldapsinglehost.php
+++ b/modules/ldapstatus/templates/ldapsinglehost.php
@@ -165,6 +165,7 @@ presentRes('ldapSearchTestUser', 'Search for test user', 'Search LDAP for the DN
 presentRes('ldapBindTestUser', 'Test user bind()', 'Trying to bind() as the DN found when searching for the test user');
 presentRes('getTestOrg', 'Get organization attributes', 'Getting attributes from referred eduOrgDN and eduOrgUnitDN (from test user)');
 presentRes('configMeta', 'Contact information registered', 'Checking for additional contact addresss in configuration.');
+presentRes('schema', 'Schema version', 'Checking if most recent version of the LDAP schema is used.');
 
 ?>
 </div><!-- end ldap status -->
diff --git a/modules/ldapstatus/templates/ldapstatus.php b/modules/ldapstatus/templates/ldapstatus.php
index 9bf913c30..04e422c59 100644
--- a/modules/ldapstatus/templates/ldapstatus.php
+++ b/modules/ldapstatus/templates/ldapstatus.php
@@ -41,6 +41,7 @@ $this->includeAtTemplateBase('includes/header.php');
 		<th><a href="?sort=ldapBindTestUser">T-bind()</a></th>
 		<th><a href="?sort=getTestOrg">Org-info</a></th>
 		<th><a href="?sort=configMeta">Meta</a></th>
+		<th><a href="?sort=schema">Schema</a></th>
 		<th><a href="?sort=time">Time</a></th>
 	</tr>
 
@@ -114,6 +115,7 @@ foreach($this->data['sortedOrgIndex'] as $orgkey) {
 		showRes('ldapBindTestUser',  $res, $this);
 		showRes('getTestOrg',  $res, $this);
 		showRes('configMeta',  $res, $this);
+		showRes('schema',  $res, $this);
 		
 		
 		if ($res['time'] > 2.0) {
-- 
GitLab