Escapes certain filter characters from an LDAP query.

def escape_query(query):
    """Escapes certain filter characters from an LDAP query."""

    return query.replace("\\", r"\5C").replace("*", r"\2A").replace("(", r"\28").replace(")", r"\29")