Skip to content

feat(ldap): Allow to search one user by one of its LDAP attribute#59928

Open
CarlSchwan wants to merge 1 commit intomasterfrom
carl/ldap-search-one-by-attribute
Open

feat(ldap): Allow to search one user by one of its LDAP attribute#59928
CarlSchwan wants to merge 1 commit intomasterfrom
carl/ldap-search-one-by-attribute

Conversation

@CarlSchwan
Copy link
Copy Markdown
Member

@CarlSchwan CarlSchwan commented Apr 27, 2026

Summary

Part of #55284

Alternative to #56721

Related PRs:

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@CarlSchwan CarlSchwan added this to the Nextcloud 34 milestone Apr 27, 2026
@CarlSchwan CarlSchwan self-assigned this Apr 27, 2026
@CarlSchwan CarlSchwan requested a review from a team as a code owner April 27, 2026 12:05
@CarlSchwan CarlSchwan requested review from come-nc, nfebe, salmart-dev and sorbaugh and removed request for a team April 27, 2026 12:05
Signed-off-by: Carl Schwan <carlschwan@kde.org>
@@ -0,0 +1,18 @@
<?php

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict types missing


#[Override]
public function getUserFromCustomAttribute(string $attribute, string $searchTerm): ?IUser {
$searchTerm = $this->access->escapeFilterPart($searchTerm);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should $attribute be escaped or validated 🤔

$records = $this->access->searchUsers($filter, ['dn']);
if (count($records) === 1) {
$ldapUser = $this->access->userManager->get($records[0]['dn'][0]);
return $this->userManager->get($ldapUser->getUsername());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should return the uid as a string to be consistent with the rest of the class and avoid having to inject UserManager in there.
Then LDAPProvider can wrap the UID in an IUser using IUserManager->getExistingUser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants