Changes to make the mockldap tests pass.

See also https://bitbucket.org/aaugustin/mockldap.

The third commit could probably be improved.