From 2481d475460da9136da5097fe5ddc3160ec0dd7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Z=C3=BCbeyde=20Civelek?= Date: Tue, 21 Apr 2026 15:04:04 +0200 Subject: [PATCH 1/2] deposit: preserve legacy_recid and _curation fields --- cds/modules/deposit/api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cds/modules/deposit/api.py b/cds/modules/deposit/api.py index 332bdbce6..1b3dc4f84 100644 --- a/cds/modules/deposit/api.py +++ b/cds/modules/deposit/api.py @@ -100,6 +100,8 @@ "_project_id", "doi", "_eos_library_path", + "legacy_recid", + "_curation" ) From 529ab1cbec53051d1ad40b3c18cac8485a441f5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Z=C3=BCbeyde=20Civelek?= Date: Tue, 21 Apr 2026 16:14:38 +0200 Subject: [PATCH 2/2] fix(ldap):add exact e-group mail match --- cds/modules/ldap/client.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/cds/modules/ldap/client.py b/cds/modules/ldap/client.py index 79c9cb720..03fd57c1a 100644 --- a/cds/modules/ldap/client.py +++ b/cds/modules/ldap/client.py @@ -121,6 +121,18 @@ def search_users_by_name(self, name): return [x[1] for x in res] def search_egroup_by_email(self, email): + # Return if exact full mail match + exact_mail = f"{email}@cern.ch" if "@" not in email else email + exact_filter = f"(mail={exact_mail})" + msgid = self.ldap.search_ext( + self.LDAP_EGROUP_BASE, + ldap.SCOPE_ONELEVEL, + exact_filter, + self.LDAP_EGROUP_RESP_FIELDS, + ) + exact_res = self.ldap.result(msgid=msgid)[1] + exact_entries = [x[1] for x in exact_res] + name_filter = "(&(mail={email}*))" self.ldap.search_ext( self.LDAP_EGROUP_BASE, @@ -129,11 +141,22 @@ def search_egroup_by_email(self, email): self.LDAP_EGROUP_RESP_FIELDS, serverctrls=[ ldap.controls.SimplePagedResultsControl( - True, size=7, cookie="" + True, size=10, cookie="" ) ], ) res = self.ldap.result()[1] + prefix_entries = [x[1] for x in res] - return [x[1] for x in res] + # Remove duplicates + seen = set() + result = [] + + for entry in exact_entries + prefix_entries: + mail = entry["mail"][0] + if mail not in seen: + seen.add(mail) + result.append(entry) + + return result