mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
find_entry_by_attr() should fail if multiple entries are found
It will only ever return one entry so if more than one are found then we raise an exception. This is most easily seen in the host plugin where we search on the server shortname which can be the same across sub-domains (e.g. foo.example.com & foo.lab.example.com). https://fedorahosted.org/freeipa/ticket/1388
This commit is contained in:
@@ -620,7 +620,12 @@ class ldap2(CrudBackend, Encoder):
|
||||
"""
|
||||
search_kw = {attr: value, 'objectClass': object_class}
|
||||
filter = self.make_filter(search_kw, rules=self.MATCH_ALL)
|
||||
return self.find_entries(filter, attrs_list, base_dn)[0][0]
|
||||
(entries, truncated) = self.find_entries(filter, attrs_list, base_dn)
|
||||
|
||||
if len(entries) > 1:
|
||||
raise errors.SingleMatchExpected(found=len(entries))
|
||||
else:
|
||||
return entries[0]
|
||||
|
||||
def get_entry(self, dn, attrs_list=None, time_limit=None,
|
||||
size_limit=None, normalize=True):
|
||||
|
||||
Reference in New Issue
Block a user