From 0ae9a2c9fefb16be52362826c8981e4efe2fa878 Mon Sep 17 00:00:00 2001 From: Jörn Friedrich Dreyer Date: Thu, 29 Sep 2016 10:16:13 +0200 Subject: Prevent user with empty uid Signed-off-by: Arthur Schiwon --- apps/user_ldap/lib/User/User.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index 3d247663b3f..51fd577104c 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -6,6 +6,7 @@ * @author Joas Schilling * @author Morris Jobke * @author Thomas Müller + * @author Jörn Friedrich Dreyer * * @license AGPL-3.0 * @@ -111,6 +112,12 @@ class User { IConfig $config, FilesystemHelper $fs, Image $image, LogWrapper $log, IAvatarManager $avatarManager, IUserManager $userManager) { + if ($username === null) { + throw new \InvalidArgumentException("uid for '$dn' must not be null!"); + } else if ($username === '') { + throw new \InvalidArgumentException("uid for '$dn' must not be an empty string!"); + } + $this->access = $access; $this->connection = $access->getConnection(); $this->config = $config; -- cgit v1.2.3 From 82c29e120404d8fe731e766c1fcd072072765943 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 6 Oct 2016 11:21:43 +0200 Subject: Log the error with display name Signed-off-by: Joas Schilling --- apps/user_ldap/lib/User/User.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/user_ldap/lib/User/User.php b/apps/user_ldap/lib/User/User.php index 51fd577104c..b2fcac10641 100644 --- a/apps/user_ldap/lib/User/User.php +++ b/apps/user_ldap/lib/User/User.php @@ -33,6 +33,7 @@ use OCP\IAvatarManager; use OCP\IConfig; use OCP\Image; use OCP\IUserManager; +use OCP\Util; /** * User @@ -113,9 +114,11 @@ class User { LogWrapper $log, IAvatarManager $avatarManager, IUserManager $userManager) { if ($username === null) { - throw new \InvalidArgumentException("uid for '$dn' must not be null!"); + $log->log("uid for '$dn' must not be null!", Util::ERROR); + throw new \InvalidArgumentException('uid must not be null!'); } else if ($username === '') { - throw new \InvalidArgumentException("uid for '$dn' must not be an empty string!"); + $log->log("uid for '$dn' must not be an empty string", Util::ERROR); + throw new \InvalidArgumentException('uid must not be an empty string!'); } $this->access = $access; -- cgit v1.2.3