4 commits - lib/api lib/Auth lib/client
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Wed Aug 22 12:59:31 CEST 2012
lib/Auth/LDAP.php | 215 +++++++++++++++++++-------------
lib/api/kolab_api_service_domain.php | 3
lib/api/kolab_api_service_domains.php | 6
lib/client/kolab_client_task_domain.php | 11 +
4 files changed, 149 insertions(+), 86 deletions(-)
New commits:
commit 0fe2bb26682f971f3544c4250d3485a03dad3607
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Aug 22 11:59:21 2012 +0100
Set title from data
diff --git a/lib/client/kolab_client_task_domain.php b/lib/client/kolab_client_task_domain.php
index b8eba82..0aec635 100644
--- a/lib/client/kolab_client_task_domain.php
+++ b/lib/client/kolab_client_task_domain.php
@@ -255,7 +255,16 @@ class kolab_client_task_domain extends kolab_client_task
}
// Edit mode
else {
- $title = $data['primary_domain'];
+ if (array_key_exists('primary_domain', $data)) {
+ $title = $data['primary_domain'];
+ }
+ // TODO: Domain name attribute.
+ else if (!is_array($data['associateddomain'])) {
+ $title = $data['associateddomain'];
+ }
+ else {
+ $title = $data['associateddomain'][0];
+ }
// Add domain type name
$fields['type_id_name'] = array(
commit a668b5eff6676afbe60c9b9ab5093fe7c2d4f0e5
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Aug 22 11:58:40 2012 +0100
Remove disabled console() messages
diff --git a/lib/api/kolab_api_service_domain.php b/lib/api/kolab_api_service_domain.php
index 1aa4813..23da894 100644
--- a/lib/api/kolab_api_service_domain.php
+++ b/lib/api/kolab_api_service_domain.php
@@ -122,8 +122,6 @@ class kolab_api_service_domain extends kolab_api_service
$auth = Auth::get_instance();
$conf = Conf::get_instance();
- //console($getdata);
-
if (!empty($getdata['domain'])) {
$entry_dn = $getdata['domain'];
@@ -146,7 +144,6 @@ class kolab_api_service_domain extends kolab_api_service
// first.
$effective_rights = $auth->list_rights($entry_dn);
- //console($effective_rights);
return $effective_rights;
}
commit 702d2e8bcc78d4cb65f484e0cf113787a10d3f6d
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Aug 22 11:57:48 2012 +0100
Correct _read() call
Correct list_resources()
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 8f8cd87..da18c67 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -236,22 +236,26 @@ class LDAP extends Net_LDAP3 {
public function domain_info($domain, $attributes = array('*')) {
$domain_dn = $this->entry_dn($domain);
+ Log::trace("Auth::LDAP::domain_info() \$domain_dn: " . $domain_dn . " and attributes: " . var_export($attributes, TRUE));
+
if (!$domain_dn) {
$domain_base_dn = $this->conf->get('ldap', 'domain_base_dn');
$domain_filter = $this->conf->get('ldap', 'domain_filter');
$domain_name_attribute = $this->conf->get('ldap', 'domain_name_attribute');
- $domain_filter = "(&$domain_filter($domain_name_attribute=$domain))";
+ $domain_filter = "(&" . $domain_filter . "(" . $domain_name_attribute . "=" . $domain . "))";
+ Log::trace("Auth::LDAP::domain_info() uses _search()");
$result = $this->_search($domain_base_dn, $domain_filter, $attributes);
} else {
- $result = $this->_read($domain_dn, '(objectclass=*)', $attributes);
+ Log::trace("Auth::LDAP::domain_info() uses _read()");
+ $result = $this->_read($domain_dn, $attributes);
}
if (!$result) {
return false;
}
- console("domain_info() result:", $result);
+ Log::trace("Auth::LDAP::domain_info() result: " . var_export($result, TRUE));
return $result;
}
@@ -379,9 +383,51 @@ class LDAP extends Net_LDAP3 {
}
public function list_domains($attributes = array(), $search = array(), $params = array()) {
- $domains = $this->domains_list();
+ $this->bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
+
+ if (!empty($params['sort_by'])) {
+ if (is_array($params['sort_by'])) {
+ foreach ($params['sort_by'] as $attrib) {
+ if (!in_array($attrib, $attributes)) {
+ $attributes[] = $attrib;
+ }
+ }
+ } else {
+ if (!in_array($params['sort_by'], $attributes)) {
+ $attributes[] = $params['sort_by'];
+ }
+ }
+ }
+
+ if (!empty($params['page_size'])) {
+ $this->config_set('page_size', $params['page_size']);
+ }
+
+ if (!empty($params['page'])) {
+ $this->config_set('list_page', $params['page']);
+ }
- return $domains->entries(TRUE);
+ if (empty($attributes) || !is_array($attributes)) {
+ $attributes = array('*');
+ }
+
+ $this->config_set('return_attributes', $attributes);
+
+ $section = $this->conf->get('kolab', 'auth_mechanism');
+ $base_dn = $this->conf->get($section, 'domain_base_dn');
+ $filter = $this->conf->get($section, 'domain_filter');
+
+ $kolab_filter = $this->conf->get($section, 'kolab_domain_filter');
+ if (empty($filter) && !empty($kolab_filter)) {
+ $filter = $kolab_filter;
+ }
+
+ $result = $this->search_entries($base_dn, $filter, 'sub', NULL, $search);
+
+ return Array(
+ 'list' => $result->entries(TRUE),
+ 'count' => $result->count()
+ );
}
public function list_groups($attributes = array(), $search = array(), $params = array()) {
@@ -430,9 +476,7 @@ class LDAP extends Net_LDAP3 {
);
}
- public function list_users($attributes = array(), $search = array(), $params = array()) {
- Log::trace("Auth::LDAP::list_users(" . var_export($attributes, TRUE) . ", " . var_export($search, TRUE) . ", " . var_export($params, TRUE));
-
+ public function list_resources($attributes = array(), $search = array(), $params = array()) {
$this->bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
if (!empty($params['sort_by'])) {
@@ -467,14 +511,25 @@ class LDAP extends Net_LDAP3 {
$this->config_set("return_attributes", $attributes);
- $base_dn = $this->conf->get('user_base_dn');
- if (empty($base_dn)) {
- $base_dn = $this->conf->get('base_dn');
+ $base_dn = $this->conf->get('resource_base_dn');
+ if (!$base_dn) {
+ $base_dn = "ou=Resources," . $this->conf->get('base_dn');
}
- $filter = $this->conf->get('user_filter');
+ $filter = $this->conf->get('resource_filter');
- Log::trace("Auth::LDAP::list_users() searching entries in $base_dn with $filter, 'sub', NULL, " . var_export($search, TRUE));
+ if (!$filter) {
+ $filter = '(&(objectclass=*)(!(objectclass=organizationalunit)))';
+ }
+
+ if (empty($attributes) || !is_array($attributes)) {
+ $attributes = array('*');
+ }
+
+ if ($s_filter = $this->search_filter($search)) {
+ // join search filter with objectClass filter
+ $filter = '(&' . $filter . $s_filter . ')';
+ }
$result = $this->search_entries($base_dn, $filter, 'sub', NULL, $search);
@@ -494,35 +549,6 @@ class LDAP extends Net_LDAP3 {
);
}
- public function list_resources($attributes = array(), $search = array(), $params = array()) {
- if (!empty($params['sort_by'])) {
- if (is_array($params['sort_by'])) {
- foreach ($params['sort_by'] as $attrib) {
- if (!in_array($attrib, $attributes)) {
- $attributes[] = $attrib;
- }
- }
- } else {
- if (!in_array($params['sort_by'], $attributes)) {
- $attributes[] = $params['sort_by'];
- }
- }
- }
-
- $resources = $this->resources_list($attributes, $search);
-
- if (!empty($params['sort_by'])) {
- $this->sort_result_key = $params['sort_by'];
- uasort($resources, array($this, 'sort_result'));
-
- if ($params['sort_order'] == 'DESC') {
- $resources = array_reverse($resources, true);
- }
- }
-
- return $resources;
- }
-
public function list_roles($attributes = array(), $search = array(), $params = array()) {
if (!empty($params['sort_by'])) {
if (!in_array($params['sort_by'], $attributes)) {
@@ -556,6 +582,70 @@ class LDAP extends Net_LDAP3 {
);
}
+ public function list_users($attributes = array(), $search = array(), $params = array()) {
+ Log::trace("Auth::LDAP::list_users(" . var_export($attributes, TRUE) . ", " . var_export($search, TRUE) . ", " . var_export($params, TRUE));
+
+ $this->bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
+
+ if (!empty($params['sort_by'])) {
+ if (is_array($params['sort_by'])) {
+ foreach ($params['sort_by'] as $attrib) {
+ if (!in_array($attrib, $attributes)) {
+ $attributes[] = $attrib;
+ }
+ }
+ } else {
+ if (!in_array($params['sort_by'], $attributes)) {
+ $attributes[] = $params['sort_by'];
+ }
+ }
+ }
+
+ if (!empty($params['page_size'])) {
+ $this->config_set('page_size', $params['page_size']);
+ } else {
+ $this->config_get('page_size', 15);
+ }
+
+ if (!empty($params['page'])) {
+ $this->config_set('list_page', $params['page']);
+ } else {
+ $this->config_set('list_page', 1);
+ }
+
+ if (empty($attributes) || !is_array($attributes)) {
+ $attributes = array('*');
+ }
+
+ $this->config_set("return_attributes", $attributes);
+
+ $base_dn = $this->conf->get('user_base_dn');
+ if (empty($base_dn)) {
+ $base_dn = $this->conf->get('base_dn');
+ }
+
+ $filter = $this->conf->get('user_filter');
+
+ Log::trace("Auth::LDAP::list_users() searching entries in $base_dn with $filter, 'sub', NULL, " . var_export($search, TRUE));
+
+ $result = $this->search_entries($base_dn, $filter, 'sub', NULL, $search);
+
+ if (!empty($params) && is_array($params) && array_key_exists('sort_by', $params)) {
+ if (is_array($params['sort_by'])) {
+ $sort = array_shift($params['sort_by']);
+ } else {
+ $sort = $params['sort_by'];
+ }
+
+ $result->sort($sort);
+ }
+
+ return Array(
+ 'list' => $result->entries(TRUE),
+ 'count' => $result->count()
+ );
+ }
+
public function resource_add($attrs, $typeid = null) {
if ($typeid == null) {
$type_str = 'resource';
@@ -870,21 +960,6 @@ class LDAP extends Net_LDAP3 {
}
}
- private function domains_list() {
- $this->bind($this->conf->get('bind_dn'), $this->conf->get('bind_pw'));
-
- $section = $this->conf->get('kolab', 'auth_mechanism');
- $base_dn = $this->conf->get($section, 'domain_base_dn');
- $filter = $this->conf->get($section, 'domain_filter');
-
- $kolab_filter = $this->conf->get($section, 'kolab_domain_filter');
- if (empty($filter) && !empty($kolab_filter)) {
- $filter = $kolab_filter;
- }
-
- return $this->_search($base_dn, $filter);
- }
-
private function groups_list($attributes = array(), $search = array()) {
$base_dn = $this->conf->get('group_base_dn');
@@ -962,30 +1037,6 @@ class LDAP extends Net_LDAP3 {
return empty($unique_attr) ? 'nsuniqueid' : $unique_attr;
}
- private function resources_list($attributes = array(), $search = array()) {
- $base_dn = $this->conf->get('resource_base_dn');
-
- if (!$base_dn) {
- $base_dn = "ou=Resources," . $this->conf->get('base_dn');
- }
-
- $filter = $this->conf->get('resource_filter');
- if (!$filter) {
- $filter = '(&(objectclass=*)(!(objectclass=organizationalunit)))';
- }
-
- if (empty($attributes) || !is_array($attributes)) {
- $attributes = array('*');
- }
-
- if ($s_filter = $this->search_filter($search)) {
- // join search filter with objectClass filter
- $filter = '(&' . $filter . $s_filter . ')';
- }
-
- return $this->_search($base_dn, $filter, $attributes);
- }
-
/**
* Qualify a username.
*
@@ -1307,7 +1358,7 @@ class LDAP extends Net_LDAP3 {
$result = $this->search($entry_dn, '(objectclass=*)', 'base');
- Log::trace("Auth::LDAP::_read() result: " . var_export($result, TRUE));
+ Log::trace("Auth::LDAP::_read() result: " . var_export($result->entries(TRUE), TRUE));
return $result ? $result->entries(TRUE) : FALSE;
}
commit 3aa40cf775e0a016021976d0c7a467e12b027b35
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Wed Aug 22 11:57:22 2012 +0100
Set $this->list_attribs for domains service
diff --git a/lib/api/kolab_api_service_domains.php b/lib/api/kolab_api_service_domains.php
index f58922e..b16c409 100644
--- a/lib/api/kolab_api_service_domains.php
+++ b/lib/api/kolab_api_service_domains.php
@@ -29,6 +29,12 @@
class kolab_api_service_domains extends kolab_api_service
{
+ public $list_attribs = array(
+ 'associatedomain',
+ 'objectclass',
+ 'entrydn',
+ );
+
/**
* Returns service capabilities.
*
More information about the commits
mailing list