It is recommended that untrusted data is never used to form a LDAP
query.

To validate data, the application should ensure that the
supplied value contains only the characters that are required to
perform the required action. For example, where a username is
required, then no non-alphanumeric characters should be accepted.

If
this is not possible, special characters should be escaped so they are
treated accordingly. The following characters should be escaped with a
`\`:

* `&` * `!` * `|` * `=` * `<` * `>` * `,` * `+` * `-` * `"` *
`'` * `;`

Additional character filtering must be applied to:

* `(` *
`)` * `\` * `/` * `*` * `NULL`

These characters require ASCII
escaping.