DB deadlocks fixed in LDAP authentication

acquireLDAPCache: guarantees there is a locked row for $form_username
replaceLDAPCacheRecord: does UPDATE instead of delete/insert