diff --git a/files/gitlab-ldap-sync.py b/files/gitlab-ldap-sync.py index e3b3f47952e25c799b1b5b9b645dcf1555a27766..943a6d7ae0acfb82803680461b39596ef62b92da 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