UUIDFix.php 853 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\User_LDAP\Migration;
  7. use OCA\User_LDAP\Mapping\AbstractMapping;
  8. use OCA\User_LDAP\Proxy;
  9. use OCA\User_LDAP\User_Proxy;
  10. use OCP\BackgroundJob\QueuedJob;
  11. abstract class UUIDFix extends QueuedJob {
  12. protected AbstractMapping $mapper;
  13. protected Proxy $proxy;
  14. public function run($argument) {
  15. $isUser = $this->proxy instanceof User_Proxy;
  16. foreach ($argument['records'] as $record) {
  17. $access = $this->proxy->getLDAPAccess($record['name']);
  18. $uuid = $access->getUUID($record['dn'], $isUser);
  19. if ($uuid === false) {
  20. // record not found, no prob, continue with the next
  21. continue;
  22. }
  23. if ($uuid !== $record['uuid']) {
  24. $this->mapper->setUUIDbyDN($uuid, $record['dn']);
  25. }
  26. }
  27. }
  28. }