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->setObjectClasses($objectclasses);
66 $cR->_validateSchemata(TRUE,TRUE);
67 $info = $cR->getSchemaResults();
68 $disabled = $cR->getDisabledPlugins();
70 // Check if the 'AT LEAST' required classes are available.
71 $smarty = get_smarty();
72 $smarty->assign('message', "");
73 $smarty->assign('database_initialised', ($res==TRUE));
74 $smarty->assign('ocCount', count($objectclasses));
76 // We are fine here once we got object classes.
77 $this->is_completed = count($objectclasses);
79 // Now check if the core requirements are fulfilled.
80 if(in_array('core', $disabled)){
81 $message = "";
82 $this->is_completed = FALSE;
83 $coreDefs = core::plInfo();
84 $coreRequired = $coreDefs['plRequirements']['ldapSchema'];
85 $missing = $version = array();
86 foreach($coreRequired as $oc => $requirement){
87 if(isset($info['missing'][$oc])){
88 $missing[$oc] = $info['missing'][$oc];
89 }
90 if(isset($info['versionMismatch'][$oc])){
91 $version[$oc] = $info['versionMismatch'][$oc];
92 }
93 }
95 $message .= "<hr>";
96 if(count($missing)){
97 $message.= _("The following object classes are missing:").msgPool::buildList(array_values($missing));
98 }
99 if(count($version)){
100 $message.= _("The following object classes are outdated:").msgPool::buildList(array_values($version));
101 }
102 $smarty->assign('message', $message);
103 }
104 $smarty->assign('checkFailed', !$this->is_completed);
105 return($smarty->fetch (get_template_path("../setup/setup_schema.tpl")));
106 }
107 }
109 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
110 ?>