/** * @brief returns a User object by it's DN or ownCloud username * @param string $id the DN or username of the user * @return \OCA\User_LDAP\User\User|\OCA\User_LDAP\User\OfflineUser|null * @throws \Exception when connection could not be established */ public function get($id) { $this->checkAccess(); if (isset($this->users['byDN'][$id])) { return $this->users['byDN'][$id]; } else { if (isset($this->users['byUid'][$id])) { return $this->users['byUid'][$id]; } } if ($this->access->stringResemblesDN($id)) { $uid = $this->access->dn2username($id); if ($uid !== false) { return $this->createAndCache($id, $uid); } } return $this->createInstancyByUserName($id); }
/** * fetches the quota from LDAP and stores it as ownCloud user value * @param string $valueFromLDAP the quota attribute's value can be passed, * to save the readAttribute request * @return null */ public function updateQuota($valueFromLDAP = null) { if ($this->wasRefreshed('quota')) { return; } //can be null $quotaDefault = $this->connection->ldapQuotaDefault; $quota = $quotaDefault !== '' ? $quotaDefault : null; $quota = !is_null($valueFromLDAP) ? $valueFromLDAP : $quota; if (is_null($valueFromLDAP)) { $quotaAttribute = $this->connection->ldapQuotaAttribute; if (!empty($quotaAttribute)) { $aQuota = $this->access->readAttribute($this->dn, $quotaAttribute); if ($aQuota && count($aQuota) > 0) { $quota = $aQuota[0]; } } } if (!is_null($quota)) { $this->userManager->get($this->uid)->setQuota($quota); } }