def _escape_filterargs(self, filterargs):
        """
        Escapes values in filterargs.

        filterargs is a value suitable for Django's string formatting operator
        (%), which means it's either a tuple or a dict. This return a new tuple
        or dict with all values escaped for use in filter strings.

        """
        if isinstance(filterargs, tuple):
            filterargs = tuple(self.ldap.filter.escape_filter_chars(value)
                               for value in filterargs)
        elif isinstance(filterargs, dict):
            filterargs = dict((key, self.ldap.filter.escape_filter_chars(value))
                              for key, value in filterargs.items())
        else:
            raise TypeError("filterargs must be a tuple or dict.")

        return filterargs