From: Frank Brehm Date: Mon, 21 Aug 2023 12:43:35 +0000 (+0200) Subject: Enabling overriding configures Base DN in lib/pp_admintools/app/ldap.py X-Git-Tag: 0.11.0~3^2~11 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=aa529ac88c01f265379a4ed08bad9582bea134c7;p=pixelpark%2Fpp-admin-tools.git Enabling overriding configures Base DN in lib/pp_admintools/app/ldap.py --- diff --git a/lib/pp_admintools/app/ldap.py b/lib/pp_admintools/app/ldap.py index 41e3e02..3779180 100644 --- a/lib/pp_admintools/app/ldap.py +++ b/lib/pp_admintools/app/ldap.py @@ -46,7 +46,7 @@ from ..config.ldap import DEFAULT_TIMEOUT from ..config.ldap import LdapConfiguration, LdapConnectionInfo from ..xlate import XLATOR, format_list -__version__ = '0.11.9' +__version__ = '0.12.0' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -435,6 +435,15 @@ class BaseLdapApplication(BaseDPXApplication): ldap_group.add_argument('-I', '--instance', **arg_params) + if not self.use_multiple_ldap_connections: + + ldap_group.add_argument( + '-b', '--base-dn', metavar='DN', dest='ldap_base_dn', + help=_( + 'Override the configured base DN of the instance used as the ' + 'root for the LDAP searches.') + ) + if self.show_cmdline_ldap_timeout: ldap_group.add_argument( '-T', '--timeout', metavar=_('SECONDS'), dest='ldap_timeout', @@ -589,6 +598,9 @@ class BaseLdapApplication(BaseDPXApplication): self._validate_given_instances(filtered_instances) + if not self.use_multiple_ldap_connections: + self._apply_target_cmdline_params(filtered_instances) + if self.verbose > 1: LOG.debug(_('LDAP instances to use:') + ' ' + pp(self.ldap_instances)) @@ -614,6 +626,15 @@ class BaseLdapApplication(BaseDPXApplication): if not all_ok: self.exit(1) + # ------------------------------------------------------------------------- + def _apply_target_cmdline_params(self, filtered_instances): + + for inst in filtered_instances: + + v = getattr(self.args, 'ldap_base_dn', None) + if v: + self.cfg.ldap_connection[inst].base_dn = v + # ------------------------------------------------------------------------- def _init_default_connection(self):