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 $schema_readable = FALSE;
28 var $attributes = array("enable_schema_check","samba_version");
29 var $enable_schema_check = TRUE;
30 var $samba_version = 3;
32 var $found_ocs = 0;
34 function Step_Schema()
35 {
36 $this->update_strings();
37 }
40 function update_strings()
41 {
42 $this->s_title = _("LDAP schema check");
43 $this->s_title_long = _("LDAP schema check");
44 $this->s_info = _("Perform test on your current LDAP schema");
45 }
48 function execute()
49 {
50 $this->check_schema();
51 $failed_checks = 0 ;
52 foreach($this->checked as $val) {
53 if(!$val['STATUS']){
54 $failed_checks ++;
55 }
56 }
58 if($failed_checks == 0){
59 $this->is_completed = TRUE;
60 }else{
61 $this->is_completed = TRUE;
62 }
64 /* Check if the database is already initialised.
65 * If the root object is missing we can't read any schema informations.
66 * In this case we should display a message.
67 */
68 $cv = $this->parent->captured_values;
70 /* Establish ldap connection */
71 $ldap = new LDAP($cv['admin'],
72 $cv['password'],
73 $cv['connection'],
74 FALSE,
75 $cv['tls']);
77 /* Check if root object exists */
78 $ldap->cd($cv['base']);
79 $res = $ldap->search("(objectClass=*)");
81 $smarty = get_smarty();
82 $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
83 $smarty->assign("database_initialised", ($res == TRUE));
84 $smarty->assign("found_ocs", $this->found_ocs);
85 $smarty->assign("schema_readable",$this->schema_readable);
86 $smarty->assign("enable_schema_check",$this->enable_schema_check);
87 $smarty->assign("checks",$this->checked);
88 $smarty->assign("not_checked",$this->not_checked);
89 $smarty->assign("failed_checks",$failed_checks);
90 return($smarty -> fetch (get_template_path("../setup/setup_schema.tpl")));
91 }
93 function save_object()
94 {
95 if(isset($_POST['step7_posted'])){
97 /* Get attributes */
98 foreach($this->attributes as $attr){
99 if(isset($_POST[$attr])){
100 $this->$attr = validate($_POST[$attr]);
101 }
102 }
103 }
104 }
106 function check_schema()
107 {
108 $cfg = $this->parent->captured_values;
109 $rfc2307bis = $cfg['rfc2307bis'];
110 $this->checked = check_schema($cfg,$rfc2307bis);
112 /* Get objectclasses */
113 $ldap = new LDAP($cfg['admin'],$cfg['password'],$cfg['connection'] ,FALSE,$cfg['tls']);
114 $objectclasses = $ldap->get_objectclasses();
115 $this->found_ocs = count($objectclasses);
117 /* Which samba version do we use? */
118 if(isset($objectclasses['sambaSamAccount'])){
119 $this->samba_version = 3;
120 } elseif(isset($objectclasses['sambaAccount'])) {
121 $this->samba_version = 2;
122 }else{
123 $this->samba_version = 0;
124 }
125 }
126 }
128 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
129 ?>