Page MenuHomePhabricator

Ambiguous message when trying to use ldap authentication 2
Open, Needs TriagePublic

Description

I am trying to use the ldap stack to authenticate versus a windows AD, I am on the setup phase, so there's probably something mistaken on my part, I am receiving a message saying Could not authenticate credentials against domain "LDAP"

Screenshot_20190711_081423.png (395×309 px, 16 KB)

Looking in the code I see two different cases for this message (LDAPAuthentication2/src/PluggableAuth.php) :

if ( !$ldapClient->canBindAs( $username, $password ) ) {
        $errorMessage =
                wfMessage(
                        'ldapauthentication2-error-authentication-failed', $domain
                )->text();
        return false;
}
try {
        $result = $ldapClient->getUserInfo( $username );
        $username = $result[$ldapClient->getConfig( ClientConfig::USERINFO_USERNAME_ATTR )];
        $realname = $result[$ldapClient->getConfig( ClientConfig::USERINFO_REALNAME_ATTR )];
        // maybe there are no emails stored in LDAP, this prevents php notices:
        $email = $result[$ldapClient->getConfig( ClientConfig::USERINFO_EMAIL_ATTR )] ?? '';
} catch ( Exception $ex ) {
        $errorMessage =
                wfMessage(
                        'ldapauthentication2-error-authentication-failed-userinfo',
                        $domain
                )->text();
        return false;
}

The first case seems to be when there is a problem binding the ldap user for the checks, the second I have no idea, is there any way to see the full log so I can get a bit more insight?

This issue is about the package ldapauthentication2 (link) but there's no specific tag on it, please relocate it if there's a better place

Event Timeline

After enabling the debug I could find that the issue was on the second bind, the one that is verifying the user credentials. Would it be possible to add the username in this error message? Without looking into debug mode, one couldn't differentiate if the issue was in the bind user (used for the initial bind) of the login user (the one we want to verify)