Fixed a bug where LDAP searches could hit a dead end