Reduce number of LDAP queries when having multiple accountBases

When searching for an account in LDAP we used to first execute one query
for each account base and, after that, check if the account was found.
For an LDAP configuration with N accountBases this always executed N
LDAP queries. In most cases this was not necessary as the account was often
found in the first configured accountBase.

Check if the account is found after each query and return as soon as it
is found. When most users are found in the first configured accountBase
this should reduce the number of LDAP queries by a factor of N.

Change-Id: I6eced365506ac9a2716cef643b5760b68fc3966d
1 file changed