From 6437b6d42cd6f19b8ff220e02319088c9819bd70 Mon Sep 17 00:00:00 2001 From: Julian Rother <julian@cccv.de> Date: Sun, 11 Dec 2022 18:56:56 +0100 Subject: [PATCH] Handle LDAP errors in sync --- files/gitlab-ldap-sync.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/files/gitlab-ldap-sync.py b/files/gitlab-ldap-sync.py index e3b3f47..943a6d7 100644 --- a/files/gitlab-ldap-sync.py +++ b/files/gitlab-ldap-sync.py @@ -54,7 +54,11 @@ def connect_ldap(host, port, encryption, ca_file, bind_dn, bind_passwd): old_search = conn.search def search(*args, **kwargs): kwargs.update({'attributes': [ldap3.ALL_ATTRIBUTES, ldap3.ALL_OPERATIONAL_ATTRIBUTES]}) - return old_search(*args, **kwargs) + ret = old_search(*args, **kwargs) + result_code = conn.result['result'] + if result_code != 0: + raise Exception(f'LDAP SEARCH failed with result code {result_code}') + return ret conn.search = search return conn -- GitLab