public function retrieveByCredentials(array $credentials = [])
{
$username = $this->getUsernameFromCredentials($credentials);
// Make sure we're connected to our LDAP server before we run any operations.
if ($username && $this->isConnected()) {
// Due to having the ability of choosing which attribute we login users
// with, we actually need to retrieve the user from our LDAP server
// before hand so we can retrieve these attributes.
$user = $this->newAdldapUserQuery()->where([$this->getUsernameValue() => $username])->first();
if ($user instanceof User) {
// Perform operations on the discovered user.
$this->handleDiscoveredUserWithCredentials($user);
return $user;
}
}
}