summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-03-14 13:25:54 +0100
committerAleksander Machniak <alec@alec.pl>2012-03-14 13:25:54 +0100
commita38db93d5516f75d77a0f5cb432fdff148c64ce3 (patch)
tree7cc804890ae71189f89854e2eff4cef6ae85f520
parent36b29501c9c6a0bda7e607d99b89ab54bc812b76 (diff)
parent6693dda50d7fa57326c6778f72f9ee3b6f12e73e (diff)
downloadwebadmin-a38db93d5516f75d77a0f5cb432fdff148c64ce3.tar.gz
Merge branch 'master' of ssh://git.kolab.org/git/kolab-wap
Conflicts: lib/client/kolab_client_task_user.php
-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 c8a6c2a..9fbffa4 100644
--- a/lib/client/kolab_client_task_user.php
+++ b/lib/client/kolab_client_task_user.php
@@ -198,9 +198,57 @@ 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(