1 <?php
3 /*
4 This code is part of GOsa (https://gosa.gonicus.de)
5 Copyright (C) 2007 Fabian Hickert
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
23 class Step_Schema extends setup_step
24 {
25 var $checked = array();
26 var $not_checked = array();
27 var $b_displayCheckbutton = true;
29 function Step_Schema()
30 {
31 $this->update_strings();
32 }
35 function update_strings()
36 {
37 $this->s_title = _("LDAP schema check");
38 $this->s_title_long = _("LDAP schema check");
39 $this->s_info = _("Perform test on your current LDAP schema");
40 }
43 function execute()
44 {
45 // Establish ldap connection
46 $cv = $this->parent->captured_values;
47 $ldap_l = new LDAP($cv['admin'],
48 $cv['password'],
49 $cv['connection'],
50 FALSE,
51 $cv['tls']);
53 // Detect Schema Info
54 $ldap = new ldapMultiplexer($ldap_l);
55 $ldap->cd($cv['base']);
56 $objectclasses = $ldap->get_objectclasses();
58 // Check if we can find something
59 $ldap->set_size_limit(1);
60 $res = $ldap->search("(objectClass=*)");
61 $ldap->set_size_limit(0);
63 // Validate schema
64 $cR = new configRegistry(NULL);;
65 $cR->validateSchemata(TRUE,TRUE,$objectclasses);
66 $info = $cR->getSchemaResults();
67 $disabled = $cR->getDisabledPlugins();
69 // Check if the 'AT LEAST' required classes are available.
70 $smarty = get_smarty();
71 $smarty->assign('message', "");
72 $smarty->assign('database_initialised', ($res==TRUE));
73 $smarty->assign('ocCount', count($objectclasses));
75 // We are fine here once we got object classes.
76 $this->is_completed = count($objectclasses);
78 // Now check if the core requirements are fulfilled.
79 if(in_array('core', $disabled)){
80 $message = "";
81 $this->is_completed = FALSE;
82 $coreDefs = core::plInfo();
83 $coreRequired = $coreDefs['plRequirements']['ldapSchema'];
84 $missing = $version = array();
85 foreach($coreRequired as $oc => $requirement){
86 if(isset($info['missing'][$oc])){
87 $missing[$oc] = $info['missing'][$oc];
88 }
89 if(isset($info['versionMismatch'][$oc])){
90 $version[$oc] = $info['versionMismatch'][$oc];
91 }
92 }
94 $message .= "<hr>";
95 if(count($missing)){
96 $message.= _("The following object classes are missing:").msgPool::buildList(array_values($missing));
97 }
98 if(count($version)){
99 $message.= _("The following object classes are outdated:").msgPool::buildList(array_values($version));
100 }
101 $smarty->assign('message', $message);
102 }
103 $smarty->assign('checkFailed', !$this->is_completed);
104 return($smarty->fetch (get_template_path("../setup/setup_schema.tpl")));
105 }
106 }
108 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
109 ?>