Skip to content

Commit

Permalink
Merge pull request #6 from nextcloud/fix/3/log-level
Browse files Browse the repository at this point in the history
fix wrong log level on success
  • Loading branch information
blizzz authored Jun 28, 2019
2 parents 1fca558 + 91aae60 commit 34e8d0e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/LDAPUserManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function createUser($username, $password) {
} catch (Exception $e) {
if ($requireActorFromLDAP) {
if ($this->configuration->isPreventFallback()) {
throw $e;
throw new \Exception('Acting admin is not from LDAP', 0, $e);
}
return false;
}
Expand All @@ -233,14 +233,19 @@ public function createUser($username, $password) {
$this->ensureAttribute($newUserEntry, $displayNameAttribute, $username);

$ret = ldap_add($connection, $newUserDN, $newUserEntry);
$message = $ret
? 'Create LDAP user \'{username}\' ({dn}'
: 'Unable to create LDAP user \'{username}\' ({dn})';
$this->logger->error($message, [

$message = 'Create LDAP user \'{username}\' ({dn})';
$level = ILogger::INFO;
if($ret === false) {
$message = 'Unable to create LDAP user \'{username}\' ({dn})';
$level = ILogger::ERROR;
}
$this->logger->log($level, $message, [
'app' => Application::APP_ID,
'username' => $username,
'dn' => $newUserDN,
]);

if (!$ret && $this->configuration->isPreventFallback()) {
throw new \Exception('Cannot create user: ' . ldap_error($connection), ldap_errno($connection));
}
Expand Down

0 comments on commit 34e8d0e

Please sign in to comment.