summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2015-01-02 09:32:34 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2015-01-02 09:32:34 (GMT)
commit17b5c924a7de8de86ce8755b9eb6d888b14fb888 (patch)
tree54fd4e31ec5630334b25a83f725bbc182ddf4dc0
parentc496f8c1354cd3ac64e951d562d922e5dd7aed71 (diff)
downloadkolab-wap-17b5c924a7de8de86ce8755b9eb6d888b14fb888.tar.gz
Support OU attribute as a base for new sharedfolder and role object (#4043)
-rw-r--r--lib/Auth/LDAP.php51
1 files changed, 20 insertions, 31 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index b80a463..b0027be 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -552,13 +552,7 @@ class LDAP extends Net_LDAP3 {
public function group_add($attrs, $typeid = null)
{
- if (!empty($attrs['ou'])) {
- $base_dn = $attrs['ou'];
- unset($attrs['ou']);
- }
- else {
- $base_dn = $this->entry_base_dn('group', $typeid);
- }
+ $base_dn = $this->entry_base_dn('group', $typeid, $attrs);
// TODO: The rdn is configurable as well.
// Use [$type_str . "_"]user_rdn_attr
@@ -724,13 +718,7 @@ class LDAP extends Net_LDAP3 {
public function organizationalunit_add($attrs, $typeid = null)
{
- if (!empty($attrs['base_dn'])) {
- $base_dn = $attrs['base_dn'];
- unset($attrs['base_dn']);
- }
- else {
- $base_dn = $this->entry_base_dn('ou', $typeid);
- }
+ $base_dn = $this->entry_base_dn('ou', $typeid, $attrs);
// TODO: The rdn is configurable as well.
// Use [$type_str . "_"]ou_rdn_attr
@@ -782,13 +770,7 @@ class LDAP extends Net_LDAP3 {
public function resource_add($attrs, $typeid = null)
{
- if (!empty($attrs['ou'])) {
- $base_dn = $attrs['ou'];
- unset($attrs['ou']);
- }
- else {
- $base_dn = $this->entry_base_dn('resource', $typeid);
- }
+ $base_dn = $this->entry_base_dn('resource', $typeid, $attrs);
// TODO: The rdn is configurable as well.
// Use [$type_str . "_"]resource_rdn_attr
@@ -839,7 +821,7 @@ class LDAP extends Net_LDAP3 {
public function role_add($attrs, $typeid = null)
{
- $base_dn = $this->entry_base_dn('role', $typeid);
+ $base_dn = $this->entry_base_dn('role', $typeid, $attrs);
// TODO: The rdn is configurable as well.
// Use [$type_str . "_"]role_rdn_attr
@@ -891,7 +873,7 @@ class LDAP extends Net_LDAP3 {
public function sharedfolder_add($attrs, $typeid = null)
{
- $base_dn = $this->entry_base_dn('sharedfolder', $typeid);
+ $base_dn = $this->entry_base_dn('sharedfolder', $typeid, $attrs);
// TODO: The rdn is configurable as well.
// Use [$type_str . "_"]user_rdn_attr
@@ -956,12 +938,7 @@ class LDAP extends Net_LDAP3 {
public function user_add($attrs, $typeid = null)
{
- $base_dn = $this->entry_base_dn('user', $typeid);
-
- if (!empty($attrs['ou'])) {
- $base_dn = $attrs['ou'];
- unset($attrs['ou']);
- }
+ $base_dn = $this->entry_base_dn('user', $typeid, $attrs);
// TODO: The rdn is configurable as well.
// Use [$type_str . "_"]user_rdn_attr
@@ -1151,9 +1128,21 @@ class LDAP extends Net_LDAP3 {
/**
* Return base DN for specified object type
*/
- protected function entry_base_dn($type, $typeid = null)
+ protected function entry_base_dn($type, $typeid = null, &$attrs = array())
{
- if ($typeid) {
+ // check if base_dn already exists in object attributes
+ if (!empty($attrs)) {
+ if (!empty($attrs['base_dn'])) {
+ $base_dn = $attrs['base_dn'];
+ unset($attrs['base_dn']);
+ }
+ else if ($type != 'ou' && !empty($attrs['ou'])) {
+ $base_dn = $attrs['ou'];
+ unset($attrs['ou']);
+ }
+ }
+
+ if (empty($base_dn) && $typeid) {
$db = SQL::get_instance();
$query = $db->query("SELECT `key` FROM `{$type}_types` WHERE `id` = ?", array($typeid));
$sql = $db->fetch_assoc($query);