diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2018-06-28 23:06:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-28 23:06:23 +0200 |
commit | 28e64afb8cb52c64e80e98416f877879889ab42f (patch) | |
tree | 8ac30c9f4b0df269d604eea9e4eaaaa4f0588aba /apps/user_ldap/lib | |
parent | 9ad0e61df6ca1d4678e534275d5c9e4586459a7c (diff) | |
parent | cc51a00c938f1c33a7dc6433954e13572fa489ae (diff) | |
download | nextcloud-server-28e64afb8cb52c64e80e98416f877879889ab42f.tar.gz nextcloud-server-28e64afb8cb52c64e80e98416f877879889ab42f.zip |
Merge pull request #10034 from nextcloud/fix/noid/ldap-silence-quota-logmsgs
lower log level for quota manipulation cases
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/Connection.php | 3 | ||||
-rw-r--r-- | apps/user_ldap/lib/User/User.php | 53 |
2 files changed, 27 insertions, 29 deletions
diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index 6140aa297b4..977b7c54425 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -57,6 +57,9 @@ use OCP\ILogger; * @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; diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index 27578921450..5dfeb6da544 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -37,8 +37,8 @@ use OCP\IAvatarManager; use OCP\IConfig; use OCP\ILogger; use OCP\Image; +use OCP\IUser; use OCP\IUserManager; -use OCP\Util; use OCP\Notification\IManager as INotificationManager; /** @@ -499,44 +499,39 @@ class User { 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); } } |