Skip to content

Commit

Permalink
Merge pull request #8074 from nextcloud/stable12-8069
Browse files Browse the repository at this point in the history
[stable12] do not catch and ignore ServerNotAvailable in the wrong spot
  • Loading branch information
MorrisJobke authored Jan 27, 2018
2 parents 15551aa + 23ffae4 commit bae874c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions apps/user_ldap/lib/Access.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,14 @@ public function getConnection() {

/**
* reads a given attribute for an LDAP record identified by a DN
*
* @param string $dn the record in question
* @param string $attr the attribute that shall be retrieved
* if empty, just check the record's existence
* @param string $filter
* @return array|false an array of values on success or an empty
* array if $attr is empty, false otherwise
* @throws ServerNotAvailableException
*/
public function readAttribute($dn, $attr, $filter = 'objectClass=*') {
if(!$this->checkConnection()) {
Expand Down Expand Up @@ -242,6 +244,7 @@ public function readAttribute($dn, $attr, $filter = 'objectClass=*') {
* @return array|bool false if there was any error, true if an exists check
* was performed and the requested DN found, array with the
* returned data on a successful usual operation
* @throws ServerNotAvailableException
*/
public function executeRead($cr, $dn, $attribute, $filter, $maxResults) {
$this->initPagedSearch($filter, array($dn), array($attribute), $maxResults, 0);
Expand Down
7 changes: 5 additions & 2 deletions apps/user_ldap/lib/User_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

namespace OCA\User_LDAP;

use OC\ServerNotAvailableException;
use OC\User\Backend;
use OC\User\NoUserException;
use OCA\User_LDAP\Exceptions\NotOnLDAP;
Expand Down Expand Up @@ -302,16 +303,18 @@ public function userExistsOnLDAP($user) {

try {
$uuid = $this->access->getUserMapper()->getUUIDByDN($dn);
if(!$uuid) {
if (!$uuid) {
return false;
}
$newDn = $this->access->getUserDnByUuid($uuid);
//check if renamed user is still valid by reapplying the ldap filter
if(!is_array($this->access->readAttribute($newDn, '', $this->access->connection->ldapUserFilter))) {
if (!is_array($this->access->readAttribute($newDn, '', $this->access->connection->ldapUserFilter))) {
return false;
}
$this->access->getUserMapper()->setDNbyUUID($newDn, $uuid);
return true;
} catch (ServerNotAvailableException $e) {
throw $e;
} catch (\Exception $e) {
return false;
}
Expand Down

0 comments on commit bae874c

Please sign in to comment.