c4784593f6d927503cc4bad9b4534662807c0828
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_l = new LDAP($cv['admin'],
72 $cv['password'],
73 $cv['connection'],
74 FALSE,
75 $cv['tls']);
77 $ldap = new ldapMultiplexer($ldap_l);
79 /* Check if root object exists */
80 $ldap->cd($cv['base']);
81 $ldap->set_size_limit(1);
82 $res = $ldap->search("(objectClass=*)");
83 $ldap->set_size_limit(0);
85 $smarty = get_smarty();
86 $smarty->assign("bool",array(FALSE => _("No"), TRUE => _("Yes")));
87 $smarty->assign("database_initialised", ($res == TRUE));
88 $smarty->assign("found_ocs", $this->found_ocs);
89 $smarty->assign("schema_readable",$this->schema_readable);
90 $smarty->assign("enable_schema_check",$this->enable_schema_check);
91 $smarty->assign("checks",$this->checked);
92 $smarty->assign("not_checked",$this->not_checked);
93 $smarty->assign("failed_checks",$failed_checks);
94 return($smarty -> fetch (get_template_path("../setup/setup_schema.tpl")));
95 }
97 function save_object()
98 {
99 if(isset($_POST['step7_posted'])){
101 /* Get attributes */
102 foreach($this->attributes as $attr){
103 if(isset($_POST[$attr])){
104 $this->$attr = validate($_POST[$attr]);
105 }
106 }
107 }
108 }
110 function check_schema()
111 {
112 $cfg = $this->parent->captured_values;
114 /* Get objectclasses */
115 $ldap = new LDAP($cfg['admin'],$cfg['password'],$cfg['connection'] ,FALSE,$cfg['tls']);
116 $objectclasses = $ldap->get_objectclasses(TRUE);
117 $this->found_ocs = count($objectclasses);
118 $rfc2307bis = $cfg['rfc2307bis'];
119 $this->checked = check_schema($cfg,$rfc2307bis);
121 /* Which samba version do we use? */
122 if(isset($objectclasses['sambaSamAccount'])){
123 $this->samba_version = 3;
124 } elseif(isset($objectclasses['sambaAccount'])) {
125 $this->samba_version = 2;
126 }else{
127 $this->samba_version = 0;
128 }
129 }
130 }
132 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
133 ?>