From: Frank Brehm Date: Mon, 21 Aug 2023 12:53:45 +0000 (+0200) Subject: Enabling more overriding configured server options in lib/pp_admintools/app/ldap.py X-Git-Tag: 0.11.0~3^2~9 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=cf21c37e3dac9215084e17f3d4414876e070a6b4;p=pixelpark%2Fpp-admin-tools.git Enabling more overriding configured server options in lib/pp_admintools/app/ldap.py --- 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):