From f983c7ad7694e8ee493304ff3a3b12ed6395e0be Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 24 May 2023 13:56:44 +0200 Subject: [PATCH] Adding additional optional parameters to methods in lib/pp_admintools/app/ldap.py --- lib/pp_admintools/app/ldap.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pp_admintools/app/ldap.py b/lib/pp_admintools/app/ldap.py index 3201748..f623a56 100644 --- a/lib/pp_admintools/app/ldap.py +++ b/lib/pp_admintools/app/ldap.py @@ -45,7 +45,7 @@ from ..config.ldap import DEFAULT_TIMEOUT from ..config.ldap import LdapConfiguration, LdapConnectionInfo from ..xlate import XLATOR, format_list -__version__ = '0.11.5' +__version__ = '0.11.6' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -772,7 +772,7 @@ class BaseLdapApplication(BaseDPXApplication): del self.ldap_server[inst] # ------------------------------------------------------------------------- - def get_all_entries(self, inst, base_dn=None, ldap_filter=None, attributes=None): + def get_all_entries(self, inst, base_dn=None, ldap_filter=None, attributes=None, scope=None): """ Get all LDAP entries bellow the given BaseDN and the given LDAP filter. @@ -782,6 +782,8 @@ class BaseLdapApplication(BaseDPXApplication): """ connect_info = self.cfg.ldap_connection[inst] ldap = self.ldap_connection[inst] + if scope is None: + scope = SUBTREE result = {} @@ -800,7 +802,7 @@ class BaseLdapApplication(BaseDPXApplication): LOG.debug(msg) req_status, req_result, req_response, req_whatever = ldap.search( - search_base=base_dn, search_scope=SUBTREE, attributes=attributes, + search_base=base_dn, search_scope=scope, attributes=attributes, search_filter=ldap_filter, time_limit=self.cfg.ldap_timeout) if req_status: @@ -832,11 +834,14 @@ class BaseLdapApplication(BaseDPXApplication): return result # ------------------------------------------------------------------------- - def get_all_entry_dns(self, inst, ldap_filter=None): + def get_all_entry_dns(self, inst, ldap_filter=None, base_dn=None, scope=None): """Get DNs of all entries in the given LDAP instance and sort them.""" connect_info = self.cfg.ldap_connection[inst] - base_dn = connect_info.base_dn + if not base_dn: + base_dn = connect_info.base_dn ldap = self.ldap_connection[inst] + if scope is None: + scope = SUBTREE result = [] -- 2.39.5