class_setupStepLdap.inc 7.85 KiB
<?php
/*
  This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  Copyright (C) 2007  Fabian Hickert
  Copyright (C) 2011-2016  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 setupStepLdap extends setupStep
  var $header_image = 'geticon.php?context=places&icon=network-server&size=48';
  var $connect_id = FALSE;
  var $bind_id    = FALSE;
  private $lastBase       = '';
  private $lastConnection = '';
  static function getAttributesInfo (): array
    return [
      'connection' => [
        'name'      => _('LDAP connection'),
        'attrs'     => [
          new StringAttribute(
            _('Location name'), _('Name of this connexion to show in the LDAP server list'),
            'location', TRUE,
            'default'
          new StringAttribute(
            _('Connection URI'), _('URI to contact the LDAP server. Usually starts with ldap://'),
            'connection', TRUE,
            'ldap://localhost:389'
          new BooleanAttribute(
            _('TLS connection'), _('Should TLS be used to connect to this LDAP server?'),
            'tls', FALSE
          new SelectAttribute(
            _('Base'), _('The LDAP directory base'),
            'base', TRUE
      'auth' => [
        'name'      => _('Authentication'),
        'attrs'     => [
          new CompositeAttribute(
            _('DN of the admin account to use for binding to the LDAP. Base is automatically appended.'),
            'admin',
              new StringAttribute(
                '', '',
                'admin_given', TRUE,
                'cn=admin'
              new DisplayAttribute(
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
'', '', 'base_append' ) ], '^(.+)(.*)$', '%s%s', '', _('Admin DN') ), new PasswordAttribute( _('Admin password'), _('Password for the admin account to use for binding to the LDAP'), 'password', TRUE ), ] ], 'status' => [ 'name' => _('Status'), 'attrs' => [ new DisplayAttribute( _('Current status'), _('Result of last attempt at checking LDAP binding and basic schemas'), 'status', FALSE ), ] ] ]; } function __construct ($parent) { parent::__construct($parent); $this->update_strings(); $this->attributesAccess['base']->setSubmitForm(TRUE); $this->attributesAccess['admin']->setLinearRendering(TRUE); $this->attributesAccess['status']->setAllowHTML(TRUE); $this->update_base_choices(); $this->status = $this->get_connection_status(); } function update_strings () { $this->s_short_name = _('LDAP setup'); $this->s_title = _('LDAP connection setup'); $this->s_description = _('This dialog performs the basic configuration of the LDAP connectivity for FusionDirectory.'); } function update_base_choices () { $attr = @LDAP::get_naming_contexts($this->connection); unset($attr['count']); if (count($attr)) { if (!($this->attributesAccess['base'] instanceof SelectAttribute)) { $this->attributesInfo['connection']['attrs']['base'] = new SelectAttribute( _('Base'), _('The LDAP directory base'), 'base', TRUE ); } $this->attributesAccess['base']->setChoices($attr); $this->attributesAccess['admin']->attributes[1]->setValue(','.$this->base); } else { $this->attributesInfo['connection']['attrs']['base'] = new StringAttribute( _('Base'), _('The LDAP directory base'), 'base', TRUE ); } $this->lastConnection = $this->connection; $this->lastBase = $this->base; } public function update (): bool { parent::update();