|
11 | 11 | use OCA\User_LDAP\User\OfflineUser; |
12 | 12 | use OCA\User_LDAP\User\User; |
13 | 13 | use OCP\IUserBackend; |
| 14 | +use OCP\LDAP\Exceptions\MultipleUsersReturnedException; |
14 | 15 | use OCP\Notification\IManager as INotificationManager; |
15 | 16 | use OCP\User\Backend\ICountMappedUsersBackend; |
16 | 17 | use OCP\User\Backend\IGetDisplayNameBackend; |
17 | 18 | use OCP\User\Backend\ILimitAwareCountUsersBackend; |
18 | 19 | use OCP\User\Backend\IPropertyPermissionBackend; |
19 | 20 | use OCP\User\Backend\IProvideEnabledStateBackend; |
20 | 21 | use OCP\UserInterface; |
| 22 | +use Override; |
21 | 23 | use Psr\Log\LoggerInterface; |
22 | 24 |
|
23 | 25 | /** |
24 | 26 | * @template-extends Proxy<User_LDAP> |
25 | 27 | */ |
26 | 28 | class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP, ILimitAwareCountUsersBackend, ICountMappedUsersBackend, IProvideEnabledStateBackend, IGetDisplayNameBackend, IPropertyPermissionBackend { |
27 | 29 | public function __construct( |
28 | | - private Helper $helper, |
| 30 | + Helper $helper, |
29 | 31 | ILDAPWrapper $ldap, |
30 | 32 | AccessFactory $accessFactory, |
31 | | - private INotificationManager $notificationManager, |
32 | | - private UserPluginManager $userPluginManager, |
33 | | - private LoggerInterface $logger, |
34 | | - private DeletedUsersIndex $deletedUsersIndex, |
| 33 | + private readonly INotificationManager $notificationManager, |
| 34 | + private readonly UserPluginManager $userPluginManager, |
| 35 | + private readonly LoggerInterface $logger, |
| 36 | + private readonly DeletedUsersIndex $deletedUsersIndex, |
35 | 37 | ) { |
36 | 38 | parent::__construct($helper, $ldap, $accessFactory); |
37 | 39 | } |
@@ -437,4 +439,19 @@ public function getDisabledUserList(?int $limit = null, int $offset = 0, string |
437 | 439 | public function canEditProperty(string $uid, string $property): bool { |
438 | 440 | return $this->handleRequest($uid, 'canEditProperty', [$uid, $property]); |
439 | 441 | } |
| 442 | + |
| 443 | + #[Override] |
| 444 | + public function getUserFromCustomAttribute(string $attribute, string $searchTerm): ?string { |
| 445 | + $this->setup(); |
| 446 | + $user = null; |
| 447 | + foreach ($this->backends as $backend) { |
| 448 | + $fetchUser = $backend->getUserFromCustomAttribute($attribute, $searchTerm); |
| 449 | + // if we found a different user, no need to continue |
| 450 | + if ($user !== null && $fetchUser !== null && $fetchUser !== $user) { |
| 451 | + throw new MultipleUsersReturnedException('Multiple users found for custom attribute search'); |
| 452 | + } |
| 453 | + $user = $fetchUser; // may be null |
| 454 | + } |
| 455 | + return $user; |
| 456 | + } |
440 | 457 | } |
0 commit comments