summaryrefslogtreecommitdiffstats
path: root/lib/Auth
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-02-27 11:31:39 +0100
committerAleksander Machniak <machniak@kolabsys.com>2014-02-27 11:31:39 +0100
commit181e61d2d947e5487694b0b8d5a709125245db48 (patch)
treeecb14eaa1dacf525edf00c07d09803ab36e46693 /lib/Auth
parent21b6f160fdb3afec0906082767de317af43d4737 (diff)
downloadwebadmin-181e61d2d947e5487694b0b8d5a709125245db48.tar.gz
Implemented OU structure management (Request #1745)
Diffstat (limited to 'lib/Auth')
-rw-r--r--lib/Auth/LDAP.php73
1 files changed, 70 insertions, 3 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 243c4ab..5e708cd 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -495,6 +495,7 @@ class LDAP extends Net_LDAP3 {
break;
case "group":
+ case "ou":
case "resource":
case "role":
case "sharedfolder":
@@ -650,6 +651,20 @@ class LDAP extends Net_LDAP3 {
return $this->_list($base_dn, $filter, 'sub', $attributes, $search, $params);
}
+ public function list_organizationalunits($attributes = array(), $search = array(), $params = array())
+ {
+ $this->_log(LOG_DEBUG, "Auth::LDAP::list_organizationalunits(" . var_export($attributes, true) . ", " . var_export($search, true) . ", " . var_export($params, true));
+
+ $base_dn = $this->_subject_base_dn('ou');
+ $filter = $this->conf->get('ou_filter');
+
+ if (!$filter) {
+ $filter = "(objectclass=organizationalunit)";
+ }
+
+ return $this->_list($base_dn, $filter, 'sub', $attributes, $search, $params);
+ }
+
public function list_resources($attributes = array(), $search = array(), $params = array())
{
$this->_log(LOG_DEBUG, "Auth::LDAP::list_resources(" . var_export($attributes, true) . ", " . var_export($search, true) . ", " . var_export($params, true));
@@ -706,12 +721,64 @@ class LDAP extends Net_LDAP3 {
return $this->_list($base_dn, $filter, 'sub', $attributes, $search, $params);
}
+ public function organizationalunit_add($attrs, $typeid = null)
+ {
+ $base_dn = $this->entry_base_dn('ou', $typeid);
+
+ // TODO: The rdn is configurable as well.
+ // Use [$type_str . "_"]ou_rdn_attr
+ $dn = "ou=" . $attrs['ou'] . "," . $base_dn;
+
+ return $this->entry_add($dn, $attrs);
+ }
+
+ public function organizationalunit_edit($ou, $attributes, $typeid = null)
+ {
+ $ou = $this->organizationalunit_info($ou, array_keys($attributes));
+
+ if (empty($ou)) {
+ return false;
+ }
+
+ $dn = key($ou);
+
+ // We should start throwing stuff over the fence here.
+ return $this->modify_entry($dn, $ou[$dn], $attributes);
+ }
+
+ public function organizationalunit_delete($ou)
+ {
+ return $this->entry_delete($ou, array('objectclass' => 'organizationalunit'));
+ }
+
+ public function organizationalunit_find_by_attribute($attribute)
+ {
+ $attribute['objectclass'] = 'organizationalunit';
+ return $this->entry_find_by_attribute($attribute);
+ }
+
+ public function organizationalunit_info($ou, $attributes = array('*'))
+ {
+ $this->_log(LOG_DEBUG, "Auth::LDAP::organizationalunit_info() for unit " . var_export($ou, true));
+ $this->bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
+
+ $dn = $this->entry_dn($ou, array('objectclass' => 'organizationalunit'));
+
+ if (!$dn) {
+ return false;
+ }
+
+ $this->read_prepare($attributes);
+
+ return $this->_read($dn, $attributes);
+ }
+
public function resource_add($attrs, $typeid = null)
{
$base_dn = $this->entry_base_dn('resource', $typeid);
// TODO: The rdn is configurable as well.
- // Use [$type_str . "_"]user_rdn_attr
+ // Use [$type_str . "_"]resource_rdn_attr
$dn = "cn=" . $attrs['cn'] . "," . $base_dn;
return $this->entry_add($dn, $attrs);
@@ -757,12 +824,12 @@ class LDAP extends Net_LDAP3 {
return $this->_read($resource_dn, $attributes);
}
- public function role_add($attrs)
+ public function role_add($attrs, $typeid = null)
{
$base_dn = $this->entry_base_dn('role', $typeid);
// TODO: The rdn is configurable as well.
- // Use [$type_str . "_"]user_rdn_attr
+ // Use [$type_str . "_"]role_rdn_attr
$dn = "cn=" . $attrs['cn'] . "," . $base_dn;
return $this->entry_add($dn, $attrs);