3 commits - lib/api lib/Auth.php lib/ext
Aleksander Machniak
machniak at kolabsys.com
Mon Oct 1 15:45:14 CEST 2012
lib/Auth.php | 5 +++++
lib/api/kolab_api_service_form_value.php | 26 +++++++++-----------------
lib/ext/Net/LDAP3.php | 17 +++++++++++++++++
3 files changed, 31 insertions(+), 17 deletions(-)
New commits:
commit d78140e171fa4f361f8d353ee46a5456c526e6dc
Author: Aleksander Machniak <alec at alec.pl>
Date: Mon Oct 1 15:44:25 2012 +0200
Implement select_options_objectclasses() with LDAP schema read
diff --git a/lib/Auth.php b/lib/Auth.php
index e1f754b..19b3857 100644
--- a/lib/Auth.php
+++ b/lib/Auth.php
@@ -410,4 +410,9 @@ class Auth {
{
return $this->auth_instance()->attributes_allowed($object_classes);
}
+
+ public function ldap_schema_classes()
+ {
+ return $this->auth_instance()->classes_allowed();
+ }
}
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index 5793cca..d7c6685 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -769,24 +769,12 @@ class kolab_api_service_form_value extends kolab_api_service
private function select_options_objectclass($postdata, $attribs = array())
{
- // @TODO: get list from LDAP
- // @TODO: filter by object type?
- $classes = array(
- 'groupofuniquenames',
- 'inetorgperson',
- 'kolabgroupofuniquenames',
- 'kolabinetorgperson',
- 'kolabsharedfolder',
- 'mailrecipient',
- 'organizationalperson',
- 'organizationalunit',
- 'person',
- 'posixaccount',
- 'posixgroup',
- 'top',
- );
+ $auth = Auth::get_instance();
+ $list = $auth->ldap_schema_classes();
+
+ sort($list);
- return array('list' => $classes);
+ return array('list' => $list);
}
private function select_options_attribute($postdata, $attribs = array())
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 3d4f897..c722fce 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -310,6 +310,19 @@ class Net_LDAP3
return array('may' => $may, 'must' => $must, 'super' => $superclasses);
}
+ public function classes_allowed()
+ {
+ $schema = $this->init_schema();
+ $list = $schema->getAll('objectclasses');
+ $classes = array();
+
+ foreach ($list as $class) {
+ $classes[] = $class['name'];
+ }
+
+ return $classes;
+ }
+
/**
* Bind connection with DN and password
*
commit be52d73380c531d7baafc13a007165810bca14b3
Author: Aleksander Machniak <alec at alec.pl>
Date: Mon Oct 1 15:21:37 2012 +0200
Return list of unique attributes from attributes_allowed()
diff --git a/lib/ext/Net/LDAP3.php b/lib/ext/Net/LDAP3.php
index 9fc7763..3d4f897 100644
--- a/lib/ext/Net/LDAP3.php
+++ b/lib/ext/Net/LDAP3.php
@@ -303,6 +303,10 @@ class Net_LDAP3
} */
}
+ $may = array_unique($may);
+ $must = array_unique($must);
+ $superclasses = array_unique($superclasses);
+
return array('may' => $may, 'must' => $must, 'super' => $superclasses);
}
commit dd495f2bdfabc120ce7c0b3903ce20aabefd9e32
Author: Aleksander Machniak <alec at alec.pl>
Date: Mon Oct 1 11:44:46 2012 +0200
Sort select_attribute() result
diff --git a/lib/api/kolab_api_service_form_value.php b/lib/api/kolab_api_service_form_value.php
index bff2aa8..5793cca 100644
--- a/lib/api/kolab_api_service_form_value.php
+++ b/lib/api/kolab_api_service_form_value.php
@@ -794,6 +794,10 @@ class kolab_api_service_form_value extends kolab_api_service
$auth = Auth::get_instance();
$list = $auth->ldap_schema_attributes($postdata['classes']);
+ if (is_array($list['may'])) {
+ sort($list['may']);
+ }
+
return array(
'list' => $list['may'],
'required' => $list['must']
More information about the commits
mailing list