summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-14 11:10:44 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-03-14 11:10:44 +0100
commit6a1b85d0e2d548c7596ad374a4007f02305ca902 (patch)
treef15acfaf3b3e720a14ce285c0b26eb5365a9e087
parent74a8a69bde41236851c099fd87cfd1e84e7acce6 (diff)
downloadwebadmin-6a1b85d0e2d548c7596ad374a4007f02305ca902.tar.gz
Update LDAP to obtain the base_dn and filter for users
Provide some routine to detect the user_type
-rw-r--r--lib/Auth/LDAP.php6
-rw-r--r--lib/client/kolab_client_task_user.php48
2 files changed, 52 insertions, 2 deletions
diff --git a/lib/Auth/LDAP.php b/lib/Auth/LDAP.php
index df20b78..5e360ed 100644
--- a/lib/Auth/LDAP.php
+++ b/lib/Auth/LDAP.php
@@ -473,8 +473,10 @@ class LDAP
public function users_list($attributes = array(), $search = array(), $params = array())
{
- $base_dn = "ou=People,dc=klab,dc=cc";
- $filter = "(objectClass=kolabinetorgperson)";
+ $conf = Conf::get_instance();
+
+ $base_dn = $conf->get('ldap', 'user_base_dn');
+ $filter = $conf->get('ldap', 'user_filter');
if (empty($attributes) || !is_array($attributes)) {
$attributes = array('*');
diff --git a/lib/client/kolab_client_task_user.php b/lib/client/kolab_client_task_user.php
index 7b21aef..aac8b8b 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -198,10 +198,58 @@ class kolab_client_task_user extends kolab_client_task
$add_mode = empty($data['user']);
$accttypes = array();
+ $result = Array();
+ $current_user_type_score = -1;
+
+ for ($i=0; $i < count($data['objectclass']); $i++) {
+ $data['objectclass'][$i] = strtolower($data['objectclass'][$i]);
+ }
+
+ $data_ocs = $data['objectclass'];
+
+ console("Data objectclasses (i.e. \$data_ocs): " . implode(", ", $data_ocs));
+
foreach ($utypes as $idx => $elem) {
+
$accttypes[$idx] = array('value' => $idx, 'content' => $elem['name']);
+
+ // Unless we're in add mode, detect the user type.
+ if (!$add_mode) {
+
+ $ref_ocs = $elem['attributes']['fields']['objectclass'];
+
+ console("Reference objectclasses (\$ref_ocs for " . $elem['key'] . "): " . implode(", ", $ref_ocs));
+
+ // Eliminate the duplicates between the $data_ocs and $ref_ocs
+ $_data_ocs = array_diff($data_ocs, $ref_ocs);
+ $_ref_ocs = array_diff($ref_ocs, $data_ocs);
+
+ console("\$data_ocs not in \$ref_ocs (" . $elem['key'] . "): " . implode(", ", $_data_ocs));
+ console("\$ref_ocs not in \$data_ocs (" . $elem['key'] . "): " . implode(", ", $_ref_ocs));
+
+ $differences = count($_data_ocs) + count($_ref_ocs);
+ $commonalities = count($data_ocs) - $differences;
+
+ console("Commonalities/differences (" . $elem['key'] . "): " . $commonalities . " / " . $differences);
+
+ if ($differences > 0) {
+ $user_type_score = ($commonalities / $differences);
+ } else {
+ $user_type_score = $commonalities;
+ }
+
+ console("Score for user type " . $elem['name'] . ": " . $user_type_score);
+
+ if ($user_type_score > $current_user_type_score) {
+ console("Score for user type " . $elem['name'] . " is greater than score for user type " . $current_user_type['name']);
+ $current_user_type = $elem;
+ $current_user_type_score = $user_type_score;
+ }
+ }
}
+ console("A little bird tells me we need to use user_type_name " . $current_user_type['name']);
+
$fields = array(
'personal' => array(
'label' => 'user.personal',