The ldap.filter module defines the following functions:
This function escapes characters in assertion_value which are special in LDAP filters. You should use this function when building LDAP filter strings from arbitrary input.
This function applies escape_filter_chars() to each of the strings in list assertion_values. After that filter_template containing as many %s placeholders as count of assertion values is used to build the whole filter string.