Bug 2128840

Summary: [RFE] provide dbus method to find users by attr
Product: Red Hat Enterprise Linux 9 Reporter: Alexey Tikhonov <atikhono>
Component: sssdAssignee: Alejandro López <allopez>
Status: CLOSED ERRATA QA Contact: shridhar <sgadekar>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.1CC: aboscatt, jvavra, pasik, pbrezina
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: sync-to-jira
Fixed In Version: sssd-2.8.1-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-05-09 08:19:51 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Alexey Tikhonov 2022-09-21 15:52:47 UTC
SSSD provides a D-Bus interface with the following methods:
- FindByName(name)
- FindByID(id)
- ListByName(filter, limit)
- ListByDomainAndName(domain, filter, limit)

It would be nice to also have a method allowing to find users that have a given attribute value: ListByAttr(ifp_attribute_name, filter, limit)

For instance, if sssd is configured with:
```
[domain/...]
ldap_user_extra_attrs = sn:sn

[ifp]
user_attributes = +sn
```
then the method ListByAttr('sn', 'alice', 0) would return all the users who have the extra attribute sn = "alice" and the method ListByAttr('sn', 'al*', 0) would return all the users who have a substring match sn="al*".

When there are multiple domains defined in sssd.conf, all the domains should be searched (note that each domain may have a different mapping). If one of the domains doesn't define the mapping, it should be skipped.

Comment 2 Alexey Tikhonov 2022-09-29 15:09:58 UTC
Upstream PR: https://github.com/SSSD/sssd/pull/6367

Comment 3 Alexey Tikhonov 2022-10-05 14:35:31 UTC
Pushed relevant PR: https://github.com/SSSD/sssd/pull/6368

* `master`
    * 3e5251bf22545ed13449e81fca64651d08f86ca4 - sssctl: Management of indexes on cache DBs.

(relevant to this BZ but doesn't resolve it)

Comment 4 Alexey Tikhonov 2022-10-07 10:46:59 UTC
Pushed PR: https://github.com/SSSD/sssd/pull/6367

* `master`
    * acfe3b292ffd75aeb0c79cc706b024a657e1ffaa - DBUS: Add ListByAttr(attr, filter, limit)

Practically this patch resolves this BZ, but I keep it assigned due to relevant issues being worked on:
 - https://github.com/SSSD/sssd/issues/6361
 - https://github.com/SSSD/sssd/issues/6360

Comment 5 Alexey Tikhonov 2022-10-11 11:38:15 UTC
Additional PR: https://github.com/SSSD/sssd/pull/6386

Comment 7 Alexey Tikhonov 2022-11-03 11:32:09 UTC
Pushed PR: https://github.com/SSSD/sssd/pull/6386

* `master`
    * c3453e4e82796c5ae578671f25568c74919cad13 - CACHE_REQ: Use a const struct in cache_req_data_create()
    * 09895561a34592de1d58af211db1725388d86d5e - TESTS: New test for D-Bus' ListByName()
    * 569dca5f24e2e92aa86c7a2800f772e29211fc31 - CACHE_REQ: Consider the domain when looking names in the cache
    * a97962826efdf5c51fed7553e761a803c48f6675 - TESTS: Correct ListByAttr()'s test
    * 8f7c35eae22aaa9649db1cf2d07d17d8c4b92e82 - CACHE_REQ: Do not return duplicated values.
    * 719c92533c52aad091c8b58e7a82b9e3b88f8e62 - CACHE_REQ: Initialize domain with NULL
    * 214540e72a6743e1112b35d562efc595594b1a82 - Cache: String has to be duplicated instead of copied
* `sssd-2-8`
    * 0f670188c3f18a63515e10ff56f03a4cbe47a845 - CACHE_REQ: Use a const struct in cache_req_data_create()
    * 7f583fad9d7604587ef1c0ff163dd9d7d337e9b2 - TESTS: New test for D-Bus' ListByName()
    * 13e841de7b31c4e341a5293acb9302beacad6015 - CACHE_REQ: Consider the domain when looking names in the cache
    * 82c69b7f601b92579c4ae0d34ea20df12cbedc11 - TESTS: Correct ListByAttr()'s test
    * 1562df030c266811b653f032131dc89a9381d81e - CACHE_REQ: Do not return duplicated values.
    * 1377bca9706179304577755b5b1e5c1dcbcd748f - CACHE_REQ: Initialize domain with NULL
    * 129979a38c38940c841134011ab866ebcf3417c7 - Cache: String has to be duplicated instead of copied

Comment 14 errata-xmlrpc 2023-05-09 08:19:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (sssd bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:2514