Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/user_ldap/lib/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
* @property string ldapUuidGroupAttribute
* @property string ldapExpertUUIDUserAttr
* @property string ldapExpertUUIDGroupAttr
* @property string ldapQuotaAttribute
* @property string ldapQuotaDefault
* @property string ldapEmailAttribute
*/
class Connection extends LDAPUtility {
private $ldapConnectionRes = null;
Expand Down
53 changes: 24 additions & 29 deletions apps/user_ldap/lib/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
use OCP\IConfig;
use OCP\ILogger;
use OCP\Image;
use OCP\IUser;
use OCP\IUserManager;
use OCP\Util;
use OCP\Notification\IManager as INotificationManager;

/**
Expand Down Expand Up @@ -499,44 +499,39 @@ public function updateQuota($valueFromLDAP = null) {
return;
}

$quotaAttribute = $this->connection->ldapQuotaAttribute;
$defaultQuota = $this->connection->ldapQuotaDefault;
if($quotaAttribute === '' && $defaultQuota === '') {
return;
}

$quota = false;
if(is_null($valueFromLDAP)) {
$quotaAttribute = $this->connection->ldapQuotaAttribute;
if ($quotaAttribute !== '') {
$aQuota = $this->access->readAttribute($this->dn, $quotaAttribute);
if($aQuota && (count($aQuota) > 0)) {
if ($this->verifyQuotaValue($aQuota[0])) {
$quota = $aQuota[0];
} else {
$this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::WARN);
}
}
if(is_null($valueFromLDAP) && $quotaAttribute !== '') {
$aQuota = $this->access->readAttribute($this->dn, $quotaAttribute);
if($aQuota && (count($aQuota) > 0) && $this->verifyQuotaValue($aQuota[0])) {
$quota = $aQuota[0];
} else if(is_array($aQuota) && isset($aQuota[0])) {
$this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $aQuota[0] . ']', ILogger::DEBUG);
}
} else if ($this->verifyQuotaValue($valueFromLDAP)) {
$quota = $valueFromLDAP;
} else {
if ($this->verifyQuotaValue($valueFromLDAP)) {
$quota = $valueFromLDAP;
} else {
$this->log->log('not suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::WARN);
}
$this->log->log('no suitable LDAP quota found for user ' . $this->uid . ': [' . $valueFromLDAP . ']', ILogger::DEBUG);
}

if ($quota === false) {
if ($quota === false && $this->verifyQuotaValue($defaultQuota)) {
// quota not found using the LDAP attribute (or not parseable). Try the default quota
$defaultQuota = $this->connection->ldapQuotaDefault;
if ($this->verifyQuotaValue($defaultQuota)) {
$quota = $defaultQuota;
}
$quota = $defaultQuota;
} else if($quota === false) {
$this->log->log('no suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::DEBUG);
return;
}

$targetUser = $this->userManager->get($this->uid);
if ($targetUser) {
if($quota !== false) {
$targetUser->setQuota($quota);
} else {
$this->log->log('not suitable default quota found for user ' . $this->uid . ': [' . $defaultQuota . ']', ILogger::WARN);
}
if ($targetUser instanceof IUser) {
$targetUser->setQuota($quota);
} else {
$this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::ERROR);
$this->log->log('trying to set a quota for user ' . $this->uid . ' but the user is missing', ILogger::INFO);
}
}

Expand Down
Loading