Ejemplo n.º 1
0
 /**
  * Create and add elements to this form
  *
  * @param   array   $formData
  */
 public function createElements(array $formData)
 {
     // LdapUserGroupBackendForm requires these factories to provide valid configurations
     ResourceFactory::setConfig($this->createResourceConfiguration());
     UserBackend::setConfig($this->createBackendConfiguration());
     $backendForm = new LdapUserGroupBackendForm();
     $formData['type'] = 'ldap';
     $backendForm->create($formData);
     $backendForm->getElement('name')->setValue('icingaweb2');
     $this->addSubForm($backendForm, 'backend_form');
     $backendForm->addElement('hidden', 'resource', array('required' => true, 'value' => $this->resourceConfig['name'], 'decorators' => array('ViewHelper')));
     $backendForm->addElement('hidden', 'user_backend', array('required' => true, 'value' => $this->backendConfig['name'], 'decorators' => array('ViewHelper')));
 }
Ejemplo n.º 2
0
 /**
  * Set up the user backend factory
  *
  * @return  $this
  */
 protected function setupUserBackendFactory()
 {
     try {
         UserBackend::setConfig(Config::app('authentication'));
     } catch (NotReadableError $e) {
         Logger::error(new IcingaException('Cannot load user backend configuration. An exception was thrown:', $e));
     }
     return $this;
 }
Ejemplo n.º 3
0
 /**
  * Create and return the user group backend
  *
  * @return  LdapUserGroupBackend
  */
 protected function createUserGroupBackend()
 {
     $resourceConfig = new Config();
     $resourceConfig->setSection($this->resourceConfig['name'], $this->resourceConfig);
     ResourceFactory::setConfig($resourceConfig);
     $backendConfig = new Config();
     $backendConfig->setSection($this->backendConfig['name'], array_merge($this->backendConfig, array('resource' => $this->resourceConfig['name'])));
     UserBackend::setConfig($backendConfig);
     if (empty($this->groupConfig)) {
         $groupConfig = new ConfigObject(array('backend' => $this->backendConfig['backend'], 'resource' => $this->resourceConfig['name'], 'user_backend' => $this->backendConfig['name']));
     } else {
         $groupConfig = new ConfigObject($this->groupConfig);
     }
     $backend = UserGroupBackend::create(null, $groupConfig);
     if (!$backend instanceof Selectable) {
         throw new NotImplementedError('Unsupported, until #9772 has been resolved');
     }
     return $backend;
 }