]> Frank Brehm's Git Trees - pixelpark/pp-admin-tools.git/commitdiff
Fixing lib/pp_admintools/ldap_app.py and lib/pp_admintools/ldap_config.py
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 5 Sep 2022 14:36:37 +0000 (16:36 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 5 Sep 2022 14:36:37 +0000 (16:36 +0200)
lib/pp_admintools/ldap_app.py
lib/pp_admintools/ldap_config.py

index 3e553144450b7727831f05b09c5cd8cde90e7cf8..d88de65e52ef9b2c006f5cfa2fce10853c889947 100644 (file)
@@ -36,7 +36,7 @@ from .ldap_config import LdapConnectionInfo, LdapConfiguration
 # rom .ldap_config import DEFAULT_PORT_LDAP, DEFAULT_PORT_LDAPS
 from .ldap_config import DEFAULT_TIMEOUT, MAX_TIMEOUT
 
-__version__ = '0.1.2'
+__version__ = '0.1.3'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -235,7 +235,7 @@ class BaseLdapApplication(FbConfigApplication):
             ldap_bind_dn = LdapConfiguration.default_bind_dn
 
             ldap_group.add_argument(
-                '-h', '--ldap-host', metavar=_("HOST"), dest="ldap_host",
+                '-H', '--ldap-host', metavar=_("HOST"), dest="ldap_host",
                 help=_(
                     "Hostname or address of the LDAP server to use. Default: {!r}").format(
                     ldap_host),
index 583be2956759ce89dfd336feec03394e15268b97..42bd06182d7fed096a53c908dca4125f700b09f0 100644 (file)
@@ -30,7 +30,7 @@ from . import MAX_PORT_NUMBER, DEFAULT_CONFIG_DIR
 
 from .xlate import XLATOR
 
-__version__ = '0.2.4'
+__version__ = '0.2.5'
 LOG = logging.getLogger(__name__)
 
 _ = XLATOR.gettext
@@ -69,12 +69,16 @@ class LdapConnectionInfo(FbBaseObject):
             appname=appname, verbose=verbose, version=version, base_dir=base_dir,
             initialized=False)
 
-        self.host = host
+        if host is not None:
+            self.host = host
         self.use_ldaps = use_ldaps
         self.port = port
-        self.base_dn = base_dn
-        self.bind_dn = bind_dn
-        self.bind_pw = bind_pw
+        if base_dn is not None:
+            self.base_dn = base_dn
+        if bind_dn is not None:
+            self.bind_dn = bind_dn
+        if bind_pw is not None:
+            self.bind_pw = bind_pw
 
         if initialized:
             self.initialized = True
@@ -345,7 +349,11 @@ class LdapConfiguration(BaseMultiConfig):
         section = self.cfg[section_name]
 
         if sn == 'ldap':
+            LOG.debug(_("Evaluating LDAP config ..."))
+
             for key in section.keys():
+                if self.verbose > 1:
+                    LOG.debug(_("Evaluating LDAP section {!r} ...").format(key))
                 sub = section[key]
                 if key.lower().strip() == 'timeout':
                     self._eval_ldap_timeout(sub)
@@ -381,6 +389,10 @@ class LdapConfiguration(BaseMultiConfig):
     # -------------------------------------------------------------------------
     def _eval_ldap_connection(self, connection_name, section):
 
+        if self.verbose > 2:
+            msg = _("Reading configuration of LDAP instance {!r} ...").format(connection_name)
+            LOG.debug(msg)
+
         connection = LdapConnectionInfo(
             appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
             initialized=False)
@@ -418,6 +430,7 @@ class LdapConfiguration(BaseMultiConfig):
                     LOG.error(msg)
                     continue
                 connection.port = port
+                continue
 
             if self.re_ldap_base_dn_key.match(key):
                 if value.strip():
@@ -431,7 +444,7 @@ class LdapConfiguration(BaseMultiConfig):
                 connection.bind_dn = value
                 continue
 
-            if self.re_ldap_bind_pw.match(key):
+            if self.re_ldap_bind_pw_key.match(key):
                 connection.bind_pw = value
                 continue