def _ldap_get_all(self, filter=None): conn = self.api.get_connection() query = '(objectClass=%s)' % (self.object_class,) if filter is not None: query = '(&%s%s)' % (filter, query) try: ret = conn.search_s(self.tree_dn, ldap.SCOPE_ONELEVEL, query) # give a chanse to other coroutine work task_switch() return ret except ldap.NO_SUCH_OBJECT: return []
def _ldap_get(self, id, filter=None): conn = self.api.get_connection() query = '(objectClass=%s)' % (self.object_class,) if filter is not None: query = '(&%s%s)' % (filter, query) try: res = conn.search_s(self._id_to_dn(id), ldap.SCOPE_BASE, query) # give a chanse to other coroutine work task_switch() except ldap.NO_SUCH_OBJECT: return None try: return res[0] except IndexError: return None