Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

User_LDAP.php 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Bart Visscher <bartv@thisnet.nl>
  7. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  8. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  9. * @author Dominik Schmidt <dev@dominik-schmidt.de>
  10. * @author felixboehm <felix@webhippie.de>
  11. * @author Joas Schilling <coding@schilljs.com>
  12. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  13. * @author Lukas Reschke <lukas@statuscode.ch>
  14. * @author Morris Jobke <hey@morrisjobke.de>
  15. * @author Robin Appelman <robin@icewind.nl>
  16. * @author Robin McCorkell <robin@mccorkell.me.uk>
  17. * @author Roger Szabo <roger.szabo@web.de>
  18. * @author root <root@localhost.localdomain>
  19. * @author Thomas Müller <thomas.mueller@tmit.eu>
  20. * @author Tom Needham <tom@owncloud.com>
  21. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  22. * @author Vinicius Cubas Brand <vinicius@eita.org.br>
  23. *
  24. * @license AGPL-3.0
  25. *
  26. * This code is free software: you can redistribute it and/or modify
  27. * it under the terms of the GNU Affero General Public License, version 3,
  28. * as published by the Free Software Foundation.
  29. *
  30. * This program is distributed in the hope that it will be useful,
  31. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. * GNU Affero General Public License for more details.
  34. *
  35. * You should have received a copy of the GNU Affero General Public License, version 3,
  36. * along with this program. If not, see <http://www.gnu.org/licenses/>
  37. *
  38. */
  39. namespace OCA\User_LDAP;
  40. use OC\ServerNotAvailableException;
  41. use OC\User\Backend;
  42. use OC\User\NoUserException;
  43. use OCA\User_LDAP\Exceptions\NotOnLDAP;
  44. use OCA\User_LDAP\User\OfflineUser;
  45. use OCA\User_LDAP\User\User;
  46. use OCP\IConfig;
  47. use OCP\IUserSession;
  48. use OCP\Notification\IManager as INotificationManager;
  49. use Psr\Log\LoggerInterface;
  50. class User_LDAP extends BackendUtility implements \OCP\IUserBackend, \OCP\UserInterface, IUserLDAP {
  51. /** @var \OCP\IConfig */
  52. protected $ocConfig;
  53. /** @var INotificationManager */
  54. protected $notificationManager;
  55. /** @var UserPluginManager */
  56. protected $userPluginManager;
  57. /** @var LoggerInterface */
  58. protected $logger;
  59. /**
  60. * @param Access $access
  61. * @param \OCP\IConfig $ocConfig
  62. * @param \OCP\Notification\IManager $notificationManager
  63. * @param IUserSession $userSession
  64. */
  65. public function __construct(Access $access, IConfig $ocConfig, INotificationManager $notificationManager, IUserSession $userSession, UserPluginManager $userPluginManager) {
  66. parent::__construct($access);
  67. $this->ocConfig = $ocConfig;
  68. $this->notificationManager = $notificationManager;
  69. $this->userPluginManager = $userPluginManager;
  70. $this->logger = \OC::$server->get(LoggerInterface::class);
  71. }
  72. /**
  73. * checks whether the user is allowed to change his avatar in Nextcloud
  74. *
  75. * @param string $uid the Nextcloud user name
  76. * @return boolean either the user can or cannot
  77. * @throws \Exception
  78. */
  79. public function canChangeAvatar($uid) {
  80. if ($this->userPluginManager->implementsActions(Backend::PROVIDE_AVATAR)) {
  81. return $this->userPluginManager->canChangeAvatar($uid);
  82. }
  83. if (!$this->implementsActions(Backend::PROVIDE_AVATAR)) {
  84. return true;
  85. }
  86. $user = $this->access->userManager->get($uid);
  87. if (!$user instanceof User) {
  88. return false;
  89. }
  90. $imageData = $user->getAvatarImage();
  91. if ($imageData === false) {
  92. return true;
  93. }
  94. return !$user->updateAvatar(true);
  95. }
  96. /**
  97. * Return the username for the given login name, if available
  98. *
  99. * @param string $loginName
  100. * @return string|false
  101. * @throws \Exception
  102. */
  103. public function loginName2UserName($loginName) {
  104. $cacheKey = 'loginName2UserName-' . $loginName;
  105. $username = $this->access->connection->getFromCache($cacheKey);
  106. if ($username !== null) {
  107. return $username;
  108. }
  109. try {
  110. $ldapRecord = $this->getLDAPUserByLoginName($loginName);
  111. $user = $this->access->userManager->get($ldapRecord['dn'][0]);
  112. if ($user === null || $user instanceof OfflineUser) {
  113. // this path is not really possible, however get() is documented
  114. // to return User, OfflineUser or null so we are very defensive here.
  115. $this->access->connection->writeToCache($cacheKey, false);
  116. return false;
  117. }
  118. $username = $user->getUsername();
  119. $this->access->connection->writeToCache($cacheKey, $username);
  120. return $username;
  121. } catch (NotOnLDAP $e) {
  122. $this->access->connection->writeToCache($cacheKey, false);
  123. return false;
  124. }
  125. }
  126. /**
  127. * returns the username for the given LDAP DN, if available
  128. *
  129. * @param string $dn
  130. * @return string|false with the username
  131. */
  132. public function dn2UserName($dn) {
  133. return $this->access->dn2username($dn);
  134. }
  135. /**
  136. * returns an LDAP record based on a given login name
  137. *
  138. * @param string $loginName
  139. * @return array
  140. * @throws NotOnLDAP
  141. */
  142. public function getLDAPUserByLoginName($loginName) {
  143. //find out dn of the user name
  144. $attrs = $this->access->userManager->getAttributes();
  145. $users = $this->access->fetchUsersByLoginName($loginName, $attrs);
  146. if (count($users) < 1) {
  147. throw new NotOnLDAP('No user available for the given login name on ' .
  148. $this->access->connection->ldapHost . ':' . $this->access->connection->ldapPort);
  149. }
  150. return $users[0];
  151. }
  152. /**
  153. * Check if the password is correct without logging in the user
  154. *
  155. * @param string $uid The username
  156. * @param string $password The password
  157. * @return false|string
  158. */
  159. public function checkPassword($uid, $password) {
  160. try {
  161. $ldapRecord = $this->getLDAPUserByLoginName($uid);
  162. } catch (NotOnLDAP $e) {
  163. $this->logger->debug(
  164. $e->getMessage(),
  165. ['app' => 'user_ldap', 'exception' => $e]
  166. );
  167. return false;
  168. }
  169. $dn = $ldapRecord['dn'][0];
  170. $user = $this->access->userManager->get($dn);
  171. if (!$user instanceof User) {
  172. $this->logger->warning(
  173. 'LDAP Login: Could not get user object for DN ' . $dn .
  174. '. Maybe the LDAP entry has no set display name attribute?',
  175. ['app' => 'user_ldap']
  176. );
  177. return false;
  178. }
  179. if ($user->getUsername() !== false) {
  180. //are the credentials OK?
  181. if (!$this->access->areCredentialsValid($dn, $password)) {
  182. return false;
  183. }
  184. $this->access->cacheUserExists($user->getUsername());
  185. $user->processAttributes($ldapRecord);
  186. $user->markLogin();
  187. return $user->getUsername();
  188. }
  189. return false;
  190. }
  191. /**
  192. * Set password
  193. * @param string $uid The username
  194. * @param string $password The new password
  195. * @return bool
  196. */
  197. public function setPassword($uid, $password) {
  198. if ($this->userPluginManager->implementsActions(Backend::SET_PASSWORD)) {
  199. return $this->userPluginManager->setPassword($uid, $password);
  200. }
  201. $user = $this->access->userManager->get($uid);
  202. if (!$user instanceof User) {
  203. throw new \Exception('LDAP setPassword: Could not get user object for uid ' . $uid .
  204. '. Maybe the LDAP entry has no set display name attribute?');
  205. }
  206. if ($user->getUsername() !== false && $this->access->setPassword($user->getDN(), $password)) {
  207. $ldapDefaultPPolicyDN = $this->access->connection->ldapDefaultPPolicyDN;
  208. $turnOnPasswordChange = $this->access->connection->turnOnPasswordChange;
  209. if (!empty($ldapDefaultPPolicyDN) && ((int)$turnOnPasswordChange === 1)) {
  210. //remove last password expiry warning if any
  211. $notification = $this->notificationManager->createNotification();
  212. $notification->setApp('user_ldap')
  213. ->setUser($uid)
  214. ->setObject('pwd_exp_warn', $uid)
  215. ;
  216. $this->notificationManager->markProcessed($notification);
  217. }
  218. return true;
  219. }
  220. return false;
  221. }
  222. /**
  223. * Get a list of all users
  224. *
  225. * @param string $search
  226. * @param integer $limit
  227. * @param integer $offset
  228. * @return string[] an array of all uids
  229. */
  230. public function getUsers($search = '', $limit = 10, $offset = 0) {
  231. $search = $this->access->escapeFilterPart($search, true);
  232. $cachekey = 'getUsers-'.$search.'-'.$limit.'-'.$offset;
  233. //check if users are cached, if so return
  234. $ldap_users = $this->access->connection->getFromCache($cachekey);
  235. if (!is_null($ldap_users)) {
  236. return $ldap_users;
  237. }
  238. // if we'd pass -1 to LDAP search, we'd end up in a Protocol
  239. // error. With a limit of 0, we get 0 results. So we pass null.
  240. if ($limit <= 0) {
  241. $limit = null;
  242. }
  243. $filter = $this->access->combineFilterWithAnd([
  244. $this->access->connection->ldapUserFilter,
  245. $this->access->connection->ldapUserDisplayName . '=*',
  246. $this->access->getFilterPartForUserSearch($search)
  247. ]);
  248. $this->logger->debug(
  249. 'getUsers: Options: search '.$search.' limit '.$limit.' offset '.$offset.' Filter: '.$filter,
  250. ['app' => 'user_ldap']
  251. );
  252. //do the search and translate results to Nextcloud names
  253. $ldap_users = $this->access->fetchListOfUsers(
  254. $filter,
  255. $this->access->userManager->getAttributes(true),
  256. $limit, $offset);
  257. $ldap_users = $this->access->nextcloudUserNames($ldap_users);
  258. $this->logger->debug(
  259. 'getUsers: '.count($ldap_users). ' Users found',
  260. ['app' => 'user_ldap']
  261. );
  262. $this->access->connection->writeToCache($cachekey, $ldap_users);
  263. return $ldap_users;
  264. }
  265. /**
  266. * checks whether a user is still available on LDAP
  267. *
  268. * @param string|\OCA\User_LDAP\User\User $user either the Nextcloud user
  269. * name or an instance of that user
  270. * @throws \Exception
  271. * @throws \OC\ServerNotAvailableException
  272. */
  273. public function userExistsOnLDAP($user, bool $ignoreCache = false): bool {
  274. if (is_string($user)) {
  275. $user = $this->access->userManager->get($user);
  276. }
  277. if (is_null($user)) {
  278. return false;
  279. }
  280. $uid = $user instanceof User ? $user->getUsername() : $user->getOCName();
  281. $cacheKey = 'userExistsOnLDAP' . $uid;
  282. if (!$ignoreCache) {
  283. $userExists = $this->access->connection->getFromCache($cacheKey);
  284. if (!is_null($userExists)) {
  285. return (bool)$userExists;
  286. }
  287. }
  288. $dn = $user->getDN();
  289. //check if user really still exists by reading its entry
  290. if (!is_array($this->access->readAttribute($dn, '', $this->access->connection->ldapUserFilter))) {
  291. try {
  292. $uuid = $this->access->getUserMapper()->getUUIDByDN($dn);
  293. if (!$uuid) {
  294. $this->access->connection->writeToCache($cacheKey, false);
  295. return false;
  296. }
  297. $newDn = $this->access->getUserDnByUuid($uuid);
  298. //check if renamed user is still valid by reapplying the ldap filter
  299. if ($newDn === $dn || !is_array($this->access->readAttribute($newDn, '', $this->access->connection->ldapUserFilter))) {
  300. $this->access->connection->writeToCache($cacheKey, false);
  301. return false;
  302. }
  303. $this->access->getUserMapper()->setDNbyUUID($newDn, $uuid);
  304. $this->access->connection->writeToCache($cacheKey, true);
  305. return true;
  306. } catch (ServerNotAvailableException $e) {
  307. throw $e;
  308. } catch (\Exception $e) {
  309. $this->access->connection->writeToCache($cacheKey, false);
  310. return false;
  311. }
  312. }
  313. if ($user instanceof OfflineUser) {
  314. $user->unmark();
  315. }
  316. $this->access->connection->writeToCache($cacheKey, true);
  317. return true;
  318. }
  319. /**
  320. * check if a user exists
  321. * @param string $uid the username
  322. * @return boolean
  323. * @throws \Exception when connection could not be established
  324. */
  325. public function userExists($uid) {
  326. $userExists = $this->access->connection->getFromCache('userExists'.$uid);
  327. if (!is_null($userExists)) {
  328. return (bool)$userExists;
  329. }
  330. //getting dn, if false the user does not exist. If dn, he may be mapped only, requires more checking.
  331. $user = $this->access->userManager->get($uid);
  332. if (is_null($user)) {
  333. $this->logger->debug(
  334. 'No DN found for '.$uid.' on '.$this->access->connection->ldapHost,
  335. ['app' => 'user_ldap']
  336. );
  337. $this->access->connection->writeToCache('userExists'.$uid, false);
  338. return false;
  339. }
  340. $this->access->connection->writeToCache('userExists'.$uid, true);
  341. return true;
  342. }
  343. /**
  344. * returns whether a user was deleted in LDAP
  345. *
  346. * @param string $uid The username of the user to delete
  347. * @return bool
  348. */
  349. public function deleteUser($uid) {
  350. if ($this->userPluginManager->canDeleteUser()) {
  351. $status = $this->userPluginManager->deleteUser($uid);
  352. if ($status === false) {
  353. return false;
  354. }
  355. }
  356. $marked = (int)$this->ocConfig->getUserValue($uid, 'user_ldap', 'isDeleted', 0);
  357. if ($marked === 0) {
  358. try {
  359. $user = $this->access->userManager->get($uid);
  360. if (($user instanceof User) && !$this->userExistsOnLDAP($uid, true)) {
  361. $user->markUser();
  362. $marked = 1;
  363. }
  364. } catch (\Exception $e) {
  365. $this->logger->debug(
  366. $e->getMessage(),
  367. ['app' => 'user_ldap', 'exception' => $e]
  368. );
  369. }
  370. if ($marked === 0) {
  371. $this->logger->notice(
  372. 'User '.$uid . ' is not marked as deleted, not cleaning up.',
  373. ['app' => 'user_ldap']
  374. );
  375. return false;
  376. }
  377. }
  378. $this->logger->info('Cleaning up after user ' . $uid,
  379. ['app' => 'user_ldap']);
  380. $this->access->getUserMapper()->unmap($uid); // we don't emit unassign signals here, since it is implicit to delete signals fired from core
  381. $this->access->userManager->invalidate($uid);
  382. $this->access->connection->clearCache();
  383. return true;
  384. }
  385. /**
  386. * get the user's home directory
  387. *
  388. * @param string $uid the username
  389. * @return bool|string
  390. * @throws NoUserException
  391. * @throws \Exception
  392. */
  393. public function getHome($uid) {
  394. // user Exists check required as it is not done in user proxy!
  395. if (!$this->userExists($uid)) {
  396. return false;
  397. }
  398. if ($this->userPluginManager->implementsActions(Backend::GET_HOME)) {
  399. return $this->userPluginManager->getHome($uid);
  400. }
  401. $cacheKey = 'getHome'.$uid;
  402. $path = $this->access->connection->getFromCache($cacheKey);
  403. if (!is_null($path)) {
  404. return $path;
  405. }
  406. // early return path if it is a deleted user
  407. $user = $this->access->userManager->get($uid);
  408. if ($user instanceof User || $user instanceof OfflineUser) {
  409. $path = $user->getHomePath() ?: false;
  410. } else {
  411. throw new NoUserException($uid . ' is not a valid user anymore');
  412. }
  413. $this->access->cacheUserHome($uid, $path);
  414. return $path;
  415. }
  416. /**
  417. * get display name of the user
  418. * @param string $uid user ID of the user
  419. * @return string|false display name
  420. */
  421. public function getDisplayName($uid) {
  422. if ($this->userPluginManager->implementsActions(Backend::GET_DISPLAYNAME)) {
  423. return $this->userPluginManager->getDisplayName($uid);
  424. }
  425. if (!$this->userExists($uid)) {
  426. return false;
  427. }
  428. $cacheKey = 'getDisplayName'.$uid;
  429. if (!is_null($displayName = $this->access->connection->getFromCache($cacheKey))) {
  430. return $displayName;
  431. }
  432. //Check whether the display name is configured to have a 2nd feature
  433. $additionalAttribute = $this->access->connection->ldapUserDisplayName2;
  434. $displayName2 = '';
  435. if ($additionalAttribute !== '') {
  436. $displayName2 = $this->access->readAttribute(
  437. $this->access->username2dn($uid),
  438. $additionalAttribute);
  439. }
  440. $displayName = $this->access->readAttribute(
  441. $this->access->username2dn($uid),
  442. $this->access->connection->ldapUserDisplayName);
  443. if ($displayName && (count($displayName) > 0)) {
  444. $displayName = $displayName[0];
  445. if (is_array($displayName2)) {
  446. $displayName2 = count($displayName2) > 0 ? $displayName2[0] : '';
  447. }
  448. $user = $this->access->userManager->get($uid);
  449. if ($user instanceof User) {
  450. $displayName = $user->composeAndStoreDisplayName($displayName, $displayName2);
  451. $this->access->connection->writeToCache($cacheKey, $displayName);
  452. }
  453. if ($user instanceof OfflineUser) {
  454. /** @var OfflineUser $user*/
  455. $displayName = $user->getDisplayName();
  456. }
  457. return $displayName;
  458. }
  459. return null;
  460. }
  461. /**
  462. * set display name of the user
  463. * @param string $uid user ID of the user
  464. * @param string $displayName new display name of the user
  465. * @return string|false display name
  466. */
  467. public function setDisplayName($uid, $displayName) {
  468. if ($this->userPluginManager->implementsActions(Backend::SET_DISPLAYNAME)) {
  469. $this->userPluginManager->setDisplayName($uid, $displayName);
  470. $this->access->cacheUserDisplayName($uid, $displayName);
  471. return $displayName;
  472. }
  473. return false;
  474. }
  475. /**
  476. * Get a list of all display names
  477. *
  478. * @param string $search
  479. * @param int|null $limit
  480. * @param int|null $offset
  481. * @return array an array of all displayNames (value) and the corresponding uids (key)
  482. */
  483. public function getDisplayNames($search = '', $limit = null, $offset = null) {
  484. $cacheKey = 'getDisplayNames-'.$search.'-'.$limit.'-'.$offset;
  485. if (!is_null($displayNames = $this->access->connection->getFromCache($cacheKey))) {
  486. return $displayNames;
  487. }
  488. $displayNames = [];
  489. $users = $this->getUsers($search, $limit, $offset);
  490. foreach ($users as $user) {
  491. $displayNames[$user] = $this->getDisplayName($user);
  492. }
  493. $this->access->connection->writeToCache($cacheKey, $displayNames);
  494. return $displayNames;
  495. }
  496. /**
  497. * Check if backend implements actions
  498. * @param int $actions bitwise-or'ed actions
  499. * @return boolean
  500. *
  501. * Returns the supported actions as int to be
  502. * compared with \OC\User\Backend::CREATE_USER etc.
  503. */
  504. public function implementsActions($actions) {
  505. return (bool)((Backend::CHECK_PASSWORD
  506. | Backend::GET_HOME
  507. | Backend::GET_DISPLAYNAME
  508. | (($this->access->connection->ldapUserAvatarRule !== 'none') ? Backend::PROVIDE_AVATAR : 0)
  509. | Backend::COUNT_USERS
  510. | (((int)$this->access->connection->turnOnPasswordChange === 1)? Backend::SET_PASSWORD :0)
  511. | $this->userPluginManager->getImplementedActions())
  512. & $actions);
  513. }
  514. /**
  515. * @return bool
  516. */
  517. public function hasUserListings() {
  518. return true;
  519. }
  520. /**
  521. * counts the users in LDAP
  522. *
  523. * @return int|bool
  524. */
  525. public function countUsers() {
  526. if ($this->userPluginManager->implementsActions(Backend::COUNT_USERS)) {
  527. return $this->userPluginManager->countUsers();
  528. }
  529. $filter = $this->access->getFilterForUserCount();
  530. $cacheKey = 'countUsers-'.$filter;
  531. if (!is_null($entries = $this->access->connection->getFromCache($cacheKey))) {
  532. return $entries;
  533. }
  534. $entries = $this->access->countUsers($filter);
  535. $this->access->connection->writeToCache($cacheKey, $entries);
  536. return $entries;
  537. }
  538. /**
  539. * Backend name to be shown in user management
  540. * @return string the name of the backend to be shown
  541. */
  542. public function getBackendName() {
  543. return 'LDAP';
  544. }
  545. /**
  546. * Return access for LDAP interaction.
  547. * @param string $uid
  548. * @return Access instance of Access for LDAP interaction
  549. */
  550. public function getLDAPAccess($uid) {
  551. return $this->access;
  552. }
  553. /**
  554. * Return LDAP connection resource from a cloned connection.
  555. * The cloned connection needs to be closed manually.
  556. * of the current access.
  557. * @param string $uid
  558. * @return resource|\LDAP\Connection The LDAP connection
  559. */
  560. public function getNewLDAPConnection($uid) {
  561. $connection = clone $this->access->getConnection();
  562. return $connection->getConnectionResource();
  563. }
  564. /**
  565. * create new user
  566. * @param string $username username of the new user
  567. * @param string $password password of the new user
  568. * @throws \UnexpectedValueException
  569. * @return bool
  570. */
  571. public function createUser($username, $password) {
  572. if ($this->userPluginManager->implementsActions(Backend::CREATE_USER)) {
  573. if ($dn = $this->userPluginManager->createUser($username, $password)) {
  574. if (is_string($dn)) {
  575. // the NC user creation work flow requires a know user id up front
  576. $uuid = $this->access->getUUID($dn, true);
  577. if (is_string($uuid)) {
  578. $this->access->mapAndAnnounceIfApplicable(
  579. $this->access->getUserMapper(),
  580. $dn,
  581. $username,
  582. $uuid,
  583. true
  584. );
  585. $this->access->cacheUserExists($username);
  586. } else {
  587. $this->logger->warning(
  588. 'Failed to map created LDAP user with userid {userid}, because UUID could not be determined',
  589. [
  590. 'app' => 'user_ldap',
  591. 'userid' => $username,
  592. ]
  593. );
  594. }
  595. } else {
  596. throw new \UnexpectedValueException("LDAP Plugin: Method createUser changed to return the user DN instead of boolean.");
  597. }
  598. }
  599. return (bool) $dn;
  600. }
  601. return false;
  602. }
  603. }