diff --git a/CHANGELOG.md b/CHANGELOG.md index f6c622c8..dfedab6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changes +- updated ldap search from name and familyname to one single attribute "displayname" + ### Deprecated ### Removed diff --git a/mex/common/ldap/extract.py b/mex/common/ldap/extract.py index 7fa371e2..74836268 100644 --- a/mex/common/ldap/extract.py +++ b/mex/common/ldap/extract.py @@ -116,38 +116,34 @@ def get_merged_ids_by_query_string( def get_persons_by_name( - surname: str = "*", - given_name: str = "*", + display_name: str = "*", **filters: str, ) -> Generator[LDAPPerson, None, None]: """Get all ldap persons matching the filters. Args: - given_name: Given name of a person, defaults to non-null. - surname: Surname of a person, defaults to non-null. + display_name: Full name of the searched person, defaults to non-null. **filters: Additional filters. Returns: Generator for LDAP persons. """ connector = LDAPConnector.get() - return connector.get_persons(surname, given_name, **filters) + return connector.get_persons(displayName=display_name, **filters) def get_count_of_found_persons_by_name( - surname: str = "*", - given_name: str = "*", + display_name: str = "*", **filters: str, ) -> int: """Get total count of found ldap persons. Args: - given_name: Given name of a person, defaults to non-null. - surname: Surname of a person, defaults to non-null. + display_name: Full name of the searched person, defaults to non-null. **filters: Additional filters. Returns: count of found persons. """ connector = LDAPConnector.get() - return len(list(connector.get_persons(surname, given_name, **filters))) + return len(list(connector.get_persons(displayName=display_name, **filters))) diff --git a/tests/ldap/test_extract.py b/tests/ldap/test_extract.py index a3aa30a8..e47568bb 100644 --- a/tests/ldap/test_extract.py +++ b/tests/ldap/test_extract.py @@ -180,7 +180,7 @@ def test_get_merged_ids_by_query_string( def test_get_persons_by_name_mocked(ldap_mocker: LDAPMocker) -> None: ldap_mocker([[SAMPLE_PERSON_ATTRS]]) - persons = get_persons_by_name(surname="Sample", given_name="Sam") + persons = get_persons_by_name(display_name="Sam Sample") persons_list = list(persons) expected = { "company": "RKI", @@ -204,7 +204,5 @@ def test_get_persons_by_name_mocked(ldap_mocker: LDAPMocker) -> None: def test_get_count_of_found_persons_by_name_mocked(ldap_mocker: LDAPMocker) -> None: ldap_mocker([[SAMPLE_PERSON_ATTRS]]) - persons_count = get_count_of_found_persons_by_name( - surname="Sample", given_name="Sam" - ) + persons_count = get_count_of_found_persons_by_name(display_name="Sam Sample") assert persons_count == 1