summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib
diff options
context:
space:
mode:
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r--apps/user_ldap/lib/access.php20
-rw-r--r--apps/user_ldap/lib/connection.php17
-rw-r--r--apps/user_ldap/lib/helper.php25
3 files changed, 59 insertions, 3 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index ad355ce5e24..a7611eb3e84 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -317,7 +317,19 @@ abstract class Access {
}
$ldapname = $ldapname[0];
}
- $intname = $isUser ? $this->sanitizeUsername($uuid) : $ldapname;
+
+ if($isUser) {
+ $usernameAttribute = $this->connection->ldapExpertUsernameAttr;
+ if(!emptY($usernameAttribute)) {
+ $username = $this->readAttribute($dn, $usernameAttribute);
+ $username = $username[0];
+ } else {
+ $username = $uuid;
+ }
+ $intname = $this->sanitizeUsername($username);
+ } else {
+ $intname = $ldapname;
+ }
//a new user/group! Add it only if it doesn't conflict with other backend's users or existing groups
//disabling Cache is required to avoid that the new user is cached as not-existing in fooExists check
@@ -897,6 +909,12 @@ abstract class Access {
return true;
}
+ $fixedAttribute = $this->connection->ldapExpertUUIDAttr;
+ if(!empty($fixedAttribute)) {
+ $this->connection->ldapUuidAttribute = $fixedAttribute;
+ return true;
+ }
+
//for now, supported (known) attributes are entryUUID, nsuniqueid, objectGUID
$testAttributes = array('entryuuid', 'nsuniqueid', 'objectguid', 'guid');
diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php
index 88ff318586a..ba4de135341 100644
--- a/apps/user_ldap/lib/connection.php
+++ b/apps/user_ldap/lib/connection.php
@@ -65,6 +65,8 @@ class Connection {
'ldapAttributesForGroupSearch' => null,
'homeFolderNamingRule' => null,
'hasPagedResultSupport' => false,
+ 'ldapExpertUsernameAttr' => null,
+ 'ldapExpertUUIDAttr' => null,
);
/**
@@ -265,6 +267,10 @@ class Connection {
= preg_split('/\r\n|\r|\n/', $this->$v('ldap_attributes_for_user_search'));
$this->config['ldapAttributesForGroupSearch']
= preg_split('/\r\n|\r|\n/', $this->$v('ldap_attributes_for_group_search'));
+ $this->config['ldapExpertUsernameAttr']
+ = $this->$v('ldap_expert_username_attr');
+ $this->config['ldapExpertUUIDAttr']
+ = $this->$v('ldap_expert_uuid_attr');
$this->configured = $this->validateConfiguration();
}
@@ -290,7 +296,6 @@ class Connection {
'ldap_group_filter'=>'ldapGroupFilter',
'ldap_display_name'=>'ldapUserDisplayName',
'ldap_group_display_name'=>'ldapGroupDisplayName',
-
'ldap_tls'=>'ldapTLS',
'ldap_nocase'=>'ldapNoCase',
'ldap_quota_def'=>'ldapQuotaDefault',
@@ -302,7 +307,9 @@ class Connection {
'ldap_turn_off_cert_check' => 'turnOffCertCheck',
'ldap_configuration_active' => 'ldapConfigurationActive',
'ldap_attributes_for_user_search' => 'ldapAttributesForUserSearch',
- 'ldap_attributes_for_group_search' => 'ldapAttributesForGroupSearch'
+ 'ldap_attributes_for_group_search' => 'ldapAttributesForGroupSearch',
+ 'ldap_expert_username_attr' => 'ldapExpertUsernameAttr',
+ 'ldap_expert_uuid_attr' => 'ldapExpertUUIDAttr',
);
return $array;
}
@@ -505,6 +512,10 @@ class Connection {
$configurationOK = false;
}
+ if(!empty($this->config['ldapExpertUUIDAttr'])) {
+ $this->config['ldapUuidAttribute'] = $this->config['ldapExpertUUIDAttr'];
+ }
+
return $configurationOK;
}
@@ -543,6 +554,8 @@ class Connection {
'ldap_configuration_active' => 1,
'ldap_attributes_for_user_search' => '',
'ldap_attributes_for_group_search' => '',
+ 'ldap_expert_username_attr' => '',
+ 'ldap_expert_uuid_attr' => '',
);
}
diff --git a/apps/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php
index 8bebd84c12e..07d13a806a6 100644
--- a/apps/user_ldap/lib/helper.php
+++ b/apps/user_ldap/lib/helper.php
@@ -102,4 +102,29 @@ class Helper {
return true;
}
+
+ /**
+ * Truncate's the given mapping table
+ *
+ * @param string $mapping either 'user' or 'group'
+ * @return boolean true on success, false otherwise
+ */
+ static public function clearMapping($mapping) {
+ if($mapping === 'user') {
+ $table = '`*PREFIX*ldap_user_mapping`';
+ } else if ($mapping === 'group') {
+ $table = '`*PREFIX*ldap_group_mapping`';
+ } else {
+ return false;
+ }
+
+ $query = \OCP\DB::prepare('TRUNCATE '.$table);
+ $res = $query->execute();
+
+ if(\OCP\DB::isError($res)) {
+ return false;
+ }
+
+ return true;
+ }
}