gitattributes: don't include tests in release tarballs

The tests are only relevant for developers; keep the release tarballs minimal.
LDAP.php: bugfixes, use escape properly

Changed some references to local variables into class properties. Add escaping
where strings are concatenated into search filters or DNs, and remove it where
no string operations are done.