Skip to content

Commit

Permalink
fix impersonating ldap users
Browse files Browse the repository at this point in the history
  • Loading branch information
butonic committed Aug 26, 2016
1 parent c120c44 commit 9af19c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<description>Allows an admin to become another user.</description>
<licence>agpl</licence>
<author>Jörn Friedrich Dreyer</author>
<version>0.0.4</version>
<version>0.0.5</version>
<dependencies>
<owncloud min-version="9.0" max-version="9.1" />
</dependencies>
Expand Down
15 changes: 7 additions & 8 deletions controller/settingscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace OCA\Impersonate\Controller;

use OCP\AppFramework\Http;
use OCP\AppFramework\Http\JSONResponse;
use OCP\ILogger;
use OCP\IRequest;
Expand Down Expand Up @@ -46,14 +47,12 @@ public function impersonate($userid) {
$oldUserId = $this->userSession->getUser()->getUID();
$this->logger->warning("User $oldUserId trying to impersonate user $userid", ['app' => 'impersonate']);

$users = $this->userManager->search($userid, 1, 0);
if (count($users) > 0) {
/** @var IUser $user */
$user = array_shift($users);
if (strcasecmp($user->getUID(), $userid) === 0) {
$this->logger->warning("changing to user $userid", ['app' => 'impersonate']);
$this->userSession->setUser($user);
}
$user = $this->userManager->get($userid);
if ($user === null) {
return new JSONResponse("No user found for $userid", Http::STATUS_NOT_FOUND);
} else {
$this->logger->warning("changing to user $userid", ['app' => 'impersonate']);
$this->userSession->setUser($user);
}
return new JSONResponse();
}
Expand Down

0 comments on commit 9af19c4

Please sign in to comment.