Security/LdapAuthenticationTrait.php
protected function setLdapCredentialsIfNeeded($username, $password, UserProviderInterface $userProvider)
    {
        // Only care about this in the context of the LDAP user provider...
        if (!$userProvider instanceof LdapUserProvider) {
            return;
        }

        // Only if the username/password are not defined in the config....
        $config = $this->ldap->getConnection()->getConfig();
        if (!(empty($config->getUsername()) && (empty($config->getPassword() && $config->getPassword() !== '0')))) {
            return;
        }

        $config->setUsername($username);
        $config->setPassword($password);
    }
protected function setLdapCredentialsIfNeeded($username, $password, UserProviderInterface $userProvider)
    {
        // Only care about this in the context of the LDAP user provider...
        if (!$userProvider instanceof LdapUserProvider) {
            return;
        }

        // Only if the username/password are not defined in the config....
        $config = $this->ldap->getConnection()->getConfig();
        if (!(empty($config->getUsername()) && (empty($config->getPassword() && $config->getPassword() !== '0')))) {
            return;
        }

        $config->setUsername($username);
        $config->setPassword($password);
    }
If no LDAP credentials are in the config then attempt to use the user supplied credentials from the login. But
only if we are using the LdapUserProvider.

@param string $username
@param string $password
@param UserProviderInterface $userProvider