summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-31 20:41:30 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-31 20:41:30 +0200
commit32cd43db6279424d14ebda304ed11356ef3d05b4 (patch)
tree5d0c401d084cdfc507026375fee908f192ac6497
parent857248878c83ac2a7a84ff43f1bafef403d4ad71 (diff)
downloadwebadmin-32cd43db6279424d14ebda304ed11356ef3d05b4.tar.gz
Discover what the RDN is by using the old LDAP object
-rw-r--r--lib/Auth/LDAP.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index abf328b..2a26c0a 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -373,8 +373,17 @@ class LDAP
public function modify_entry($subject_dn, $old_attrs, $new_attrs)
{
+ console($old_attrs);
+
// TODO: Get $rdn_attr - we have type_id in $new_attrs
- $rdn_attr = 'cn';
+ $dn_components = ldap_explode_dn($subject_dn, 0);
+ $rdn_components = explode('=', $dn_components[0]);
+
+ $rdn_attr = $rdn_components[0];
+
+ console($rdn_attr);
+
+// return;
$mod_array = Array(
"add" => Array(), // For use with ldap_mod_add()
@@ -439,15 +448,19 @@ class LDAP
$result = ldap_mod_replace($this->conn, $subject_dn, $attributes['replace']);
}
- if (!$result)
+ if (!$result) {
+ console("Failed to replace the following attributes", $attributes['replace']);
return false;
+ }
if (is_array($attributes['add']) && !empty($attributes['add'])) {
$result = ldap_mod_add($this->conn, $subject_dn, $attributes['add']);
}
- if (!$result)
+ if (!$result) {
+ console("Failed to add the following attributes", $attributes['add']);
return false;
+ }
if (is_array($attributes['rename']) && !empty($attributes['rename'])) {
$olddn = key($attributes['rename']);
@@ -455,13 +468,15 @@ class LDAP
$result = ldap_rename($this->conn, $olddn, $newrdn, NULL, true);
}
- if (!$result)
+ if (!$result) {
return false;
+ }
- if ($result)
+ if ($result) {
return true;
- else
+ } else {
return false;
+ }
}
public function user_add($attrs, $type = null)