From 9502a3c47c3d1784576a4380a3a8d95a932ad8cc Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Thu, 17 Dec 2009 17:19:58 -0500 Subject: [PATCH] Add configldap definition, similar to configsql --- framework/Core/lib/Horde/Config.php | 142 ++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/framework/Core/lib/Horde/Config.php b/framework/Core/lib/Horde/Config.php index 6b4c44140..57e741c54 100644 --- a/framework/Core/lib/Horde/Config.php +++ b/framework/Core/lib/Horde/Config.php @@ -542,6 +542,10 @@ class Horde_Config } break; + case 'configldap': + $conf[$node->get_attribute('switchname')] = $this->_configLDAP($ctx, $node); + break; + case 'configphp': $conf[$name] = array( '_type' => 'php', @@ -608,6 +612,144 @@ class Horde_Config } /** + * Returns the configuration tree for an LDAP backend configuration to + * replace a tag. + * Subnodes will be parsed and added to both the Horde defaults and the + * Custom configuration parts. + * + * @param string $ctx The context of the tag. + * @param DomNode $node The DomNode representation of the + * tag. + * @param string $switchname If DomNode is not set, the value of the + * tag's switchname attribute. + * + * @return array An associative array with the SQL configuration tree. + */ + protected function _configLDAP($ctx, $node = null, + $switchname = 'driverconfig') + { + $hostspec = array( + '_type' => 'text', + 'required' => true, + 'desc' => 'LDAP server/hostname', + 'default' => $this->_default($ctx . '|hostspec', '') + ); + + $searchdn = array( + '_type' => 'text', + 'required' => false, + 'desc' => 'DN used to bind to LDAP for searches (blank for anonymous)', + 'default' => $this->_default($ctx . '|searchdn', '') + ); + + $searchpw = array( + '_type' => 'text', + 'required' => false, + 'desc' => 'Password for search bind DN (blank for anonymous)', + 'default' => $this->_default($ctx . '|searchpw', '') + ); + + $basedn = array( + '_type' => 'text', + 'required' => true, + 'desc' => 'Base DN', + 'default' => $this->_default($ctx . '|basedn', '') + ); + + $port = array( + '_type' => 'int', + 'required' => false, + 'desc' => 'Port on which LDAP is listening, if non-standard', + 'default' => $this->_default($ctx . '|port', null) + ); + + $writedn = array( + 'desc' => 'Bind to LDAP as which user when performing writes?', + 'default' => $this->_default($ctx . '|writedn', 'search'), + 'switch' => array( + 'user' => array( + 'desc' => 'Bind as the currently logged-in user', + ), + 'admin' => array( + 'desc' => 'Bind with administrative/system credentials', + 'fields' => array( + 'binddn' => array( + '_type' => 'text', + 'required' => true, + 'desc' => 'DN used to bind to LDAP for writes', + 'default' => $this->_default($ctx . '|writedn', '') + ), + 'bindpw' => array( + '_type' => 'text', + 'required' => true, + 'desc' => 'Password for write bind DN', + 'default' => $this->_default($ctx . '|writepw', '') + ) + ) + ), + 'search' => array( + 'desc' => 'Use same credentials as used for LDAP searches' + ) + ) + ); + + $tls = array( + '_type' => 'boolean', + 'required' => false, + 'desc' => 'Use TLS to connect to the server?', + 'default' => $this->_default($ctx . '|tls', false) + ); + + $ca = array( + '_type' => 'text', + 'required' => false, + 'desc' => 'Certification Authority to use for SSL connections', + 'default' => $this->_default($ctx . '|ca', '') + ); + + $custom_fields = array( + 'hostspec' => $hostspec, + 'port' => $port, + 'tls' => $tls, + 'searchdn' => $searchdn, + 'searchpw' => $searchpw, + 'basedn' => $basedn, + 'writedn' => $writedn, + 'ca' => $ca + ); + + if (isset($node) && $node->get_attribute('baseconfig') == 'true') { + return $custom_fields; + } + + list($default, $isDefault) = $this->__default($ctx . '|' . (isset($node) ? $node->get_attribute('switchname') : $switchname), 'horde'); + $config = array( + 'desc' => 'Driver configuration', + 'default' => $default, + 'is_default' => $isDefault, + 'switch' => array( + 'horde' => array( + 'desc' => 'Horde defaults', + 'fields' => array() + ), + 'custom' => array( + 'desc' => 'Custom parameters', + 'fields' => $custom_fields + ) + ) + ); + + if (isset($node) && $node->has_child_nodes()) { + $cur = array(); + $this->_parseLevel($cur, $node->child_nodes(), $ctx); + $config['switch']['horde']['fields'] = array_merge($config['switch']['horde']['fields'], $cur); + $config['switch']['custom']['fields'] = array_merge($config['switch']['custom']['fields'], $cur); + } + + return $config; + } + + /** * Returns the configuration tree for an SQL backend configuration to * replace a tag. * Subnodes will be parsed and added to both the Horde defaults and the -- 2.11.0