]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Enabling more overriding configured server options in lib/pp_admintools/app/ldap.py
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 21 Aug 2023 12:53:45 +0000 (14:53 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 21 Aug 2023 12:53:45 +0000 (14:53 +0200)
lib/pp_admintools/app/ldap.py

index 37791809ef2486fe8a6183766d353518da096825..55270221e322029cc909f9eee2c6f5657e566560 100644 (file)
@@ -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):