summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-30 18:35:49 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-30 18:35:49 +0200
commitafa582a38e00123e9d57e91421f80d3254f8fafe (patch)
treea65d9573478434753242eb41e9af908ec9ef9c61
parent1d91f501f4516033d10741483186ac743f9c7fd8 (diff)
downloadwebadmin-afa582a38e00123e9d57e91421f80d3254f8fafe.tar.gz
Make adding groups work
Strip empty attribute values from the ldap_add() function call, as it seems to not be able to digest those
-rw-r--r--lib/Auth.php5
-rw-r--r--lib/Auth/LDAP.php39
2 files changed, 44 insertions, 0 deletions
diff --git a/lib/Auth.php b/lib/Auth.php
index 7b7b379..dfafc06 100644
--- a/lib/Auth.php
+++ b/lib/Auth.php
@@ -171,6 +171,11 @@ class Auth {
return $this->_auth[$_SESSION['user']->get_domain()]->find_user_groups($member_dn);
}
+ public function group_add($attributes, $type=NULL)
+ {
+ return $this->_auth[$_SESSION['user']->get_domain()]->group_add($attributes, $type);
+ }
+
public function group_info($groupdata)
{
return $this->_auth[$_SESSION['user']->get_domain()]->group_info($groupdata);
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index 5aff9f6..73701b7 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -460,6 +460,36 @@ class LDAP
return $groups;
}
+ public function group_add($attrs, $type = null)
+ {
+ if ($type == null) {
+ $type_str = 'group';
+ }
+ else {
+ $db = SQL::get_instance();
+ $_key = $db->fetch_assoc($db->query("SELECT `key` FROM group_types WHERE id = ?", $type));
+ $type_str = $_key['key'];
+ }
+
+ // Check if the user_type has a specific base DN specified.
+ $base_dn = $this->conf->get($this->domain, $type_str . "_group_base_dn");
+ // If not, take the regular user_base_dn
+ if (!$base_dn)
+ $base_dn = $this->conf->get($this->domain, "group_base_dn");
+
+ // If no user_base_dn either, take the user type specific from the parent
+ // configuration
+ if (!$base_dn)
+ $base_dn = $this->conf->get('ldap', $type_str . "_group_base_dn");
+
+ // TODO: The rdn is configurable as well.
+ // Use [$type_str . "_"]user_rdn_attr
+ $dn = "cn=" . $attrs['cn'] . "," . $base_dn;
+
+ return $this->_add($dn, $attrs);
+ }
+
+
public function group_info($group)
{
$is_dn = ldap_explode_dn($group, 1);
@@ -795,6 +825,15 @@ class LDAP
// Always bind with the session credentials
$this->_bind($_SESSION['user']->user_bind_dn, $_SESSION['user']->user_bind_pw);
+// console("Entry DN", $entry_dn);
+// console("Attributes", $attributes);
+
+ foreach ($attributes as $attr_name => $attr_value) {
+ if (empty($attr_value)) {
+ unset($attributes[$attr_name]);
+ }
+ }
+
if (($add_result = ldap_add($this->conn, $entry_dn, $attributes)) == false) {
// Issue warning
return false;