Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-03-28 15:18:24 +0400
committerArthur Schiwon <blizzz@owncloud.com>2014-03-28 15:18:24 +0400
commit7dd34b12126483a24ef6370b23ec9e87cc988c8c (patch)
tree5c3a374b99bd4a96b5b0c97bf44f8e64938031c7 /apps/user_ldap
parent24274acd6a236152d97e2b74346efd4b5bedd037 (diff)
LDAP: Read email and quota when mapping user, fixes #7785
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib/access.php46
-rw-r--r--apps/user_ldap/user_ldap.php35
2 files changed, 48 insertions, 33 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index bab81292e2d..aaf3994cfe8 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -105,6 +105,47 @@ class Access extends LDAPUtility {
return false;
}
+ public function updateQuota($dn, $ocname = null) {
+ $quota = null;
+ $quotaDefault = $this->connection->ldapQuotaDefault;
+ $quotaAttribute = $this->connection->ldapQuotaAttribute;
+ if(!empty($quotaDefault)) {
+ $quota = $quotaDefault;
+ }
+ if(!empty($quotaAttribute)) {
+ $aQuota = $this->readAttribute($dn, $quotaAttribute);
+
+ if($aQuota && (count($aQuota) > 0)) {
+ $quota = $aQuota[0];
+ }
+ }
+ if(!is_null($quota)) {
+ if(is_null($ocname)) {
+ $ocname = $this->dn2username($dn);
+ }
+ \OCP\Config::setUserValue($ocname, 'files', 'quota',
+ \OCP\Util::computerFileSize($quota));
+ }
+ }
+
+ public function updateEmail($dn, $ocname = null) {
+ $email = null;
+ $emailAttribute = $this->connection->ldapEmailAttribute;
+ if(!empty($emailAttribute)) {
+ $aEmail = $this->readAttribute($dn, $emailAttribute);
+ if($aEmail && (count($aEmail) > 0)) {
+ $email = $aEmail[0];
+ }
+ if(!is_null($email)) {
+ if(is_null($ocname)) {
+ $ocname = $this->dn2username($dn);
+ }
+ \OCP\Config::setUserValue($ocname, 'settings', 'email', $email);
+ }
+ }
+ }
+
+
/**
* @brief checks wether the given attribute`s valua is probably a DN
* @param $attr the attribute in question
@@ -598,6 +639,11 @@ class Access extends LDAPUtility {
return false;
}
+ if($isUser) {
+ $this->updateEmail($dn, $ocname);
+ $this->updateQuota($dn, $ocname);
+ }
+
return true;
}
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index c993a1de4aa..f2353dfa0db 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -31,42 +31,11 @@ use OCA\user_ldap\lib\BackendUtility;
class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
private function updateQuota($dn) {
- $quota = null;
- $quotaDefault = $this->access->connection->ldapQuotaDefault;
- $quotaAttribute = $this->access->connection->ldapQuotaAttribute;
- if(!empty($quotaDefault)) {
- $quota = $quotaDefault;
- }
- if(!empty($quotaAttribute)) {
- $aQuota = $this->access->readAttribute($dn, $quotaAttribute);
-
- if($aQuota && (count($aQuota) > 0)) {
- $quota = $aQuota[0];
- }
- }
- if(!is_null($quota)) {
- \OCP\Config::setUserValue( $this->access->dn2username($dn),
- 'files',
- 'quota',
- \OCP\Util::computerFileSize($quota));
- }
+ $this->access->updateQuota($dn);
}
private function updateEmail($dn) {
- $email = null;
- $emailAttribute = $this->access->connection->ldapEmailAttribute;
- if(!empty($emailAttribute)) {
- $aEmail = $this->access->readAttribute($dn, $emailAttribute);
- if($aEmail && (count($aEmail) > 0)) {
- $email = $aEmail[0];
- }
- if(!is_null($email)) {
- \OCP\Config::setUserValue( $this->access->dn2username($dn),
- 'settings',
- 'email',
- $email);
- }
- }
+ $this->access->updateEmail($dn);
}
/**