File: class_setupStep_Schema.inc

package info (click to toggle)
fusiondirectory 1.0.8.2-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 28,984 kB
  • sloc: php: 74,645; xml: 3,645; perl: 1,555; pascal: 705; sh: 135; sql: 45; makefile: 19
file content (128 lines) | stat: -rw-r--r-- 3,927 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php

/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2007  Fabian Hickert
  Copyright (C) 2011-2013  FusionDirectory

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/

class Step_Schema extends setup_step
{
  var $checked              = array();
  var $not_checked          = array();
  var $schema_readable      = FALSE;
  var $attributes           = array("enable_schema_check","samba_version");
  var $enable_schema_check  = TRUE;
  var $samba_version        = 3;
  var $header_image         = 'geticon.php?context=types&icon=user&size=48';

  var $found_ocs = 0;

  function __construct()
  {
    $this->update_strings();
  }


  function update_strings()
  {
    $this->s_title      = _("LDAP schema check");
    $this->s_title_long = _("LDAP schema check");
    $this->s_info       = _("Perform test on your current LDAP schema");
  }


  function execute()
  {
    global $BASE_DIR;
    $this->check_schema();
    $failed_checks = 0;
    foreach ($this->checked as $val) {
      if (!$val['STATUS']) {
        $failed_checks ++;
      }
    }

    if ($failed_checks == 0) {
      $this->is_completed = TRUE;
    } else {
      $this->is_completed = TRUE;
    }

    /* Check if the database is already initialised.
     * If the root object is missing we can't read any schema informations.
     * In this case we should display a message.
     */

    /* Establish ldap connection */
    $cv   = $this->parent->captured_values;
    $ldap = $this->get_ldap_link();

    /* Check if root object exists */
    $ldap->cd($cv['base']);
    $ldap->set_size_limit(1);
    $res = $ldap->search("(objectClass=*)");
    $ldap->set_size_limit(0);

    $smarty = get_smarty();
    $smarty->assign("bool",                 array(FALSE => _("No"), TRUE => _("Yes")));
    $smarty->assign("database_initialised", ($res == TRUE));
    $smarty->assign("found_ocs",            $this->found_ocs);
    $smarty->assign("schema_readable",      $this->schema_readable);
    $smarty->assign("enable_schema_check",  $this->enable_schema_check);
    $smarty->assign("checks",               $this->checked);
    $smarty->assign("not_checked",          $this->not_checked);
    $smarty->assign("failed_checks",        $failed_checks);

    return $smarty->fetch("$BASE_DIR/setup/setup_schema.tpl");
  }

  function save_object()
  {
    if (isset($_POST['step7_posted'])) {
      /* Get attributes */
      foreach ($this->attributes as $attr) {
        if (isset($_POST[$attr])) {
          $this->$attr = validate($_POST[$attr]);
        }
      }
    }
  }

  function check_schema()
  {
    $cfg = $this->parent->captured_values;

    /* Get objectclasses */
    $ldap             = new LDAP($cfg['admin'], $cfg['password'], $cfg['connection'], FALSE, $cfg['tls']);
    $objectclasses    = $ldap->get_objectclasses(TRUE);
    $this->found_ocs  = count($objectclasses);
    $rfc2307bis       = $cfg['rfc2307bis'];
    $this->checked    = check_schema($cfg, $rfc2307bis);

    /* Which samba version do we use? */
    if (isset($objectclasses['sambaSamAccount'])) {
      $this->samba_version = 3;
    } elseif (isset($objectclasses['sambaAccount'])) {
      $this->samba_version = 2;
    } else {
      $this->samba_version = 0;
    }
  }
}

?>