Branch 'dev/configuration-handling' - 3 commits - lib/Auth lib/Conf.php lib/kolab_client_task.php
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Fri Mar 30 13:16:03 CEST 2012
lib/Auth/LDAP.php | 43 ++++++++++++++++++++++++++-----------------
lib/Conf.php | 2 +-
lib/kolab_client_task.php | 8 +++++++-
3 files changed, 34 insertions(+), 19 deletions(-)
New commits:
commit e39ec68a94c12786d7ec6648ed253e90c62ae07c
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Mar 30 12:15:49 2012 +0100
Return false rather than null
diff --git a/lib/Conf.php b/lib/Conf.php
index d843cdd..7c35baf 100644
--- a/lib/Conf.php
+++ b/lib/Conf.php
@@ -131,7 +131,7 @@ class Conf {
" with \$key2: " . $key2
);
- return null;
+ return false;
}
public function expand($str, $custom = FALSE)
commit 4fc11aa0deea5a4e1b2b94adaf1fdc3dd831305f
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Mar 30 12:15:32 2012 +0100
More verbose loggin
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 010e1ce..d454215 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -104,7 +104,10 @@ class kolab_client_task
*/
private function api_init()
{
- $url = $this->config_get('api_url', '');
+ $url = $this->config_get('api_url', '');
+
+ // TODO: Debug logging
+ console($url);
if (!$url) {
$url = kolab_utils::https_check() ? 'https://' : 'http://';
@@ -113,6 +116,9 @@ class kolab_client_task
$url .= '/api';
}
+ // TODO: Debug logging
+ console($url);
+
$this->api = new kolab_client_api($url);
}
commit 03686454c92239b44848767eadce9097aeec8223
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Fri Mar 30 12:13:54 2012 +0100
Use more items from configuration
Circumvent bootstrap catch-22 during login
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 7c5b658..f09e37f 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -68,7 +68,12 @@ class LDAP
if (!isset($domain) || empty($domain)) {
// If not, attempt to get the domain from the session.
if (isset($_SESSION['user'])) {
- $domain = $_SESSION['user']->get_domain();
+ try {
+ $domain = $_SESSION['user']->get_domain();
+ } catch (Exception $e) {
+ // TODO: Debug logging
+ error_log("Warning, user not authenticated yet");
+ }
}
}
@@ -183,11 +188,11 @@ class LDAP
'/usr/lib64/mozldap/ldapsearch',
'-x',
'-h',
- // TODO: Get from conf
- 'ldap.klab.cc',
+ $this->_ldap_server,
+ '-p',
+ $this->_ldap_port,
'-b',
- // TODO: Get from conf
- 'dc=klab,dc=cc',
+ $conf->get('base_dn'),
'-D',
'"' . $_SESSION['user']->user_bind_dn . '"',
'-w',
@@ -560,8 +565,12 @@ class LDAP
{
$conf = Conf::get_instance();
- $base_dn = $conf->get('ldap', 'user_base_dn');
- $filter = $conf->get('ldap', 'user_filter');
+ $base_dn = $conf->get('user_base_dn');
+
+ if (!$base_dn)
+ $base_dn = $conf->get('base_dn');
+
+ $filter = $conf->get('user_filter');
if (empty($attributes) || !is_array($attributes)) {
$attributes = array('*');
@@ -579,8 +588,7 @@ class LDAP
{
$conf = Conf::get_instance();
- // TODO: From config
- $base_dn = "dc=klab,dc=cc";
+ $base_dn = $conf->get('base_dn');
// TODO: From config
$filter = "(&(objectclass=ldapsubentry)(objectclass=nsroledefinition))";
@@ -598,14 +606,12 @@ class LDAP
private function groups_list($attributes = array(), $search = array())
{
- // TODO: From config
- $base_dn = "ou=Groups,dc=klab,dc=cc";
- // TODO: From config
- $filter = "(|"
- ."(objectClass=kolabgroupofnames)"
- ."(objectclass=kolabgroupofuniquenames)"
- ."(objectclass=kolabgroupofurls)"
- .")";
+ $base_dn = $conf->get('group_base_dn');
+
+ if (!$base_dn)
+ $base_dn = $conf->get('base_dn');
+
+ $filter = $conf->get('group_filter');
if (empty($attributes) || !is_array($attributes)) {
$attributes = array('*');
@@ -641,6 +647,7 @@ class LDAP
else {
$result[$dn][$attr] = array();
for ($z = 0; $z < $__result[$x][$attr]["count"]; $z++) {
+ // The first result in the array is the primary domain.
if ($z == 0 && $attr == $dn_attr) {
$result[$dn]['primary_domain'] = $__result[$x][$attr][$z];
}
@@ -1102,6 +1109,7 @@ class LDAP
private function _get_group_dn($root_dn, $search_filter)
{
+ // TODO: Why does this use privileged credentials?
if (($this->_bind($this->conf->get('bind_dn'), $this->conf->get('bind_pw'))) == false) {
$this->_bind($this->conf->get('manager_bind_dn'), $this->conf->get('manager_bind_pw'));
}
@@ -1124,6 +1132,7 @@ class LDAP
private function _get_user_dn($root_dn, $search_filter)
{
+ // TODO: Why does this use privileged credentials?
if (($this->_bind($this->conf->get('bind_dn'), $this->conf->get('bind_pw'))) == false) {
//message("WARNING: Invalid Service bind credentials supplied");
$this->_bind($this->conf->get('manager_bind_dn'), $this->conf->get('manager_bind_pw'));
More information about the commits
mailing list