from ..config.ldap import LdapConfiguration, LdapConnectionInfo
from ..xlate import XLATOR, format_list
-__version__ = '0.12.1'
+__version__ = '0.12.2'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
instances = []
for inst in self.cfg.ldap_connection.keys():
+ cfg = self.cfg.ldap_connection[inst]
+ if not cfg.valid:
+ continue
if inst != self.default_default_ldap_instance:
instances.append(inst)
instances.sort(key=str.lower)
url = '{url}/{base}'.format(url=cfg.url, base=cfg.base_dn)
if len(url) > max_url_len:
max_url_len = len(url)
- if len(cfg.bind_dn) > max_bind_dn_len:
- max_bind_dn_len = len(cfg.bind_dn)
+ bind_dn = cfg.bind_dn
+ if not bind_dn:
+ bind_dn = ''
+ if len(bind_dn) > max_bind_dn_len:
+ max_bind_dn_len = len(bind_dn)
max_key_len += 1
for inst in instances:
cfg = self.cfg.ldap_connection[inst]
url = '{url}/{base}'.format(url=cfg.url, base=cfg.base_dn)
+ bind_dn = cfg.bind_dn
+ if not bind_dn:
+ bind_dn = ''
print(tpl.format(
- inst=(inst + ':'), width=max_key_len, url=url, bind_dn=cfg.bind_dn,
+ inst=(inst + ':'), width=max_key_len, url=url, bind_dn=bind_dn,
bind_dn_l=max_bind_dn_len, url_l=max_url_len, tier=cfg.tier))
print()
if inst == 'default':
continue
instance = self.cfg.ldap_connection[inst]
+ if not instance.valid:
+ continue
if is_admin is not None:
if to_bool(is_admin) != instance.is_admin:
continue
from .. import MAX_PORT_NUMBER
from ..xlate import XLATOR
-__version__ = '0.7.1'
+__version__ = '0.8.0'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
res['tier'] = self.tier
res['url'] = self.url
res['use_ldaps'] = self.use_ldaps
+ res['valid'] = self.valid
if self.bind_pw:
if self.verbose > 4:
return
self._admin_dn = str(value).strip()
+ # -----------------------------------------------------------
+ @property
+ def valid(self):
+ """Shows, whether the current connection info is valid and usable."""
+ if not self.host:
+ return False
+ if not self.port:
+ return False
+ if not self.base_dn:
+ return False
+ if self.bind_dn:
+ if not self.bind_pw:
+ return False
+ if not self.admin_dn:
+ return False
+ if not self.initialized:
+ return False
+ return True
+
# -------------------------------------------------------------------------
def __repr__(self):
"""Cast the type into a string for reproduction."""