def _check_server_uri(self): if not any([ self.config.server_uri.startswith('ldap://') or self.config.server_uri.startswith('ldaps://') ]): err = _('ldap:// or ldaps:// protocol is used.') raise LDAPInvalidServerError(err)
def test_server_uri(self): try: self._test_server_uri() except LDAPSocketOpenError as e: error = _("Host or port is disconnected: {}").format(e) except LDAPSessionTerminatedByServerError as e: error = _('The port is not the port of the LDAP service: {}').format(e) except LDAPSocketReceiveError as e: error = _('Please add certificate: {}').format(e) except Exception as e: error = _('Unknown error: {}').format(e) else: return raise LDAPInvalidServerError(error)