def _handle_referral(self, exception): univention.debug.debug(univention.debug.LDAP, univention.debug.INFO, 'Following LDAP referral') exc = exception.args[0] info = exc.get('info') ldap_url = info[info.find('ldap'):] if isLDAPUrl(ldap_url): conn_str = LDAPUrl(ldap_url).initializeUrl() lo_ref = ldap.ldapobject.ReconnectLDAPObject(conn_str, trace_stack_limit=None) if self.ca_certfile: lo_ref.set_option(ldap.OPT_X_TLS_CACERTFILE, self.ca_certfile) if self.start_tls == 1: try: lo_ref.start_tls_s() except: univention.debug.debug(univention.debug.LDAP, univention.debug.WARN, 'Could not start TLS') elif self.start_tls == 2: lo_ref.start_tls_s() lo_ref.simple_bind_s(self.binddn, self.__encode_pwd(self.bindpw)) return lo_ref else: raise ldap.CONNECT_ERROR('Bad referral "%s"' % (exc,))
def _handle_referral(self, exception): """ Handle a referral specified in the passed-in exception """ payload = exception.args[0] info = payload.get('info') ldap_url = info[info.find('ldap'):] if ldapurl.isLDAPUrl(ldap_url): conn_str = ldapurl.LDAPUrl(ldap_url).initializeUrl() conn = self._connect(conn_str) conn.simple_bind_s(self._encode_incoming(self.bind_dn), self._encode_incoming(self.bind_pwd)) return conn else: raise ldap.CONNECT_ERROR('Bad referral "%s"' % str(exception))
def _handle_referral(self, exception): # type: (ldap.REFERRAL) -> ldap.ldapobject.ReconnectLDAPObject """ Follow LDAP rederral. :param exception ldap.REFERRAL: The LDAP referral exception. :returns: LDAP connection object for the referred LDAP server. :rtype: ldap.ldapobject.ReconnectLDAPObject """ univention.debug.debug(univention.debug.LDAP, univention.debug.INFO, 'Following LDAP referral') exc = exception.args[0] info = exc.get('info') ldap_url = info[info.find('ldap'):] if isLDAPUrl(ldap_url): conn_str = LDAPUrl(ldap_url).initializeUrl() # FIXME?: this upgrades a access(reconnect=False) connection to a reconnect=True connection lo_ref = ldap.ldapobject.ReconnectLDAPObject( conn_str, trace_stack_limit=None) if self.ca_certfile: lo_ref.set_option(ldap.OPT_X_TLS_CACERTFILE, self.ca_certfile) if self.start_tls == 1: try: lo_ref.start_tls_s() except: univention.debug.debug(univention.debug.LDAP, univention.debug.WARN, 'Could not start TLS') elif self.start_tls == 2: lo_ref.start_tls_s() lo_ref.simple_bind_s(self.binddn, self.__encode_pwd(self.bindpw)) return lo_ref else: raise ldap.CONNECT_ERROR('Bad referral "%s"' % (exc, ))
def handle_referral(self, exception): """ Handle a referral specified in a exception """ payload = exception.args[0] info = payload.get('info') ldap_url = info[info.find('ldap'):] if isLDAPUrl(ldap_url): conn_str = LDAPUrl(ldap_url).initializeUrl() if self.binduid_usage == 1: user_dn = self.bind_dn user_pwd = self.bind_pwd else: user = getSecurityManager().getUser() try: user_dn = user.getUserDN() user_pwd = user._getPassword() except AttributeError: # User object is not a LDAPUser user_dn = user_pwd = '' return self._connect(conn_str, user_dn, user_pwd) else: raise ldap.CONNECT_ERROR('Bad referral "%s"' % str(exception))