from ldap3 import BASE, SUBTREE
from ldap3 import Connection, DSA, IP_V4_PREFERRED, SAFE_SYNC, Server
from ldap3 import MODIFY_ADD, MODIFY_DELETE, MODIFY_REPLACE
+from ldap3.core.exceptions import LDAPBindError
from ldap3.core.exceptions import LDAPException
# Own modules
from ..config.ldap import LdapConfiguration, LdapConnectionInfo
from ..xlate import XLATOR, format_list
-__version__ = '0.11.8'
+__version__ = '0.11.9'
LOG = logging.getLogger(__name__)
_ = XLATOR.gettext
url=connect_info.url, dn=bind_dn)
LOG.debug(msg)
- ldap_connection = Connection(
- ldap_server, bind_dn, bind_pw, client_strategy=SAFE_SYNC, auto_bind=True)
+ try:
+ ldap_connection = Connection(
+ ldap_server, bind_dn, bind_pw, client_strategy=SAFE_SYNC, auto_bind=True)
+ except LDAPBindError as e:
+ msg = _('Could not connect to LDAP server {url!r} as {user!r}: {e}.').format(
+ url=connect_info.url, user=bind_dn, e=e)
+ LOG.error(msg)
+ self.exit(8)
+ except LDAPException as e:
+ msg = _('{c} on connecting to LDAP server {url!r} as {user!r}: {e}.').format(
+ c=e.__class__.__name__, url=connect_info.url, user=bind_dn, e=e)
+ LOG.error(msg)
+ self.exit(9)
return ldap_connection
def post_run(self):
"""Execute after the the payload action of the application."""
LOG.debug(_('Finishing ...'))
+
super(BaseLdapApplication, self).post_run()
self.disconnect_all()