From cf21c37e3dac9215084e17f3d4414876e070a6b4 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 21 Aug 2023 14:53:45 +0200 Subject: [PATCH] Enabling more overriding configured server options in lib/pp_admintools/app/ldap.py --- lib/pp_admintools/app/ldap.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/pp_admintools/app/ldap.py b/lib/pp_admintools/app/ldap.py index 3779180..5527022 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.12.0' +__version__ = '0.12.1' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -437,6 +437,18 @@ class BaseLdapApplication(BaseDPXApplication): if not self.use_multiple_ldap_connections: + ldap_group.add_argument( + '-H', '--ldap-host', metavar=_('HOST'), dest='ldap_host', + help=_( + 'Override configured hostname or address of the LDAP server.') + ) + + ldap_group.add_argument( + '-p', '--ldap-port', metavar=_('PORT'), type=int, dest='ldap_port', + action=LdapPortOptionAction, + help=_('Override the configured port number to connect to the LDAP server.') + ) + ldap_group.add_argument( '-b', '--base-dn', metavar='DN', dest='ldap_base_dn', help=_( @@ -631,10 +643,26 @@ class BaseLdapApplication(BaseDPXApplication): for inst in filtered_instances: + v = getattr(self.args, 'ldap_host', None) + if v: + self.cfg.ldap_connection[inst].host = v + + v = getattr(self.args, 'ldap_port', None) + if v is not None: + self.cfg.ldap_connection[inst].port = v + v = getattr(self.args, 'ldap_base_dn', None) if v: self.cfg.ldap_connection[inst].base_dn = v + v = getattr(self.args, 'ldap_bind_dn', None) + if v: + self.cfg.ldap_connection[inst].bind_dn = v + + v = getattr(self.args, 'ldap_bind_pw', None) + if v: + self.cfg.ldap_connection[inst].bind_pw = v + # ------------------------------------------------------------------------- def _init_default_connection(self): -- 2.39.5