User_LDAP.php 20 KB

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