Page MenuHomePhabricator

Improve debug when user not found in LDAP search
Open, Needs TriagePublic

Description

When \MediaWiki\Extension\LDAPProvider\Client does not find a user, the array returned will be empty in:
https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/LDAPAuthentication2/+/refs/heads/master/src/PluggableAuth.php#191

When just trying to access the result with:

			$username = $result[$ldapClient->getConfig( ClientConfig::USERINFO_USERNAME_ATTR )];
			$realname = $result[$ldapClient->getConfig( ClientConfig::USERINFO_REALNAME_ATTR )];

There is a notice issued:
[Wed Jul 20 06:46:39.008311 2022] [php7:notice] [pid 922747] [client 10.0.0.45:34006] PHP Notice: Undefined index: samaccountname in .../www/extensions/LDAPAuthentication2/src/PluggableAuth.php on line 192, referer: .../index.php?title=Special:UserLogin&returnto=Main+Page

It would be good to handle the case when user was not found explicitly.
What would be great is to add some debug / warning information that the user was not found for given LDAP query & base. This would help a lot in troubleshooting LDAP settings - it took me some time to figure out I had a wrong base DN!
I was getting error:
The supplied credentials are not associated with any user on this wiki.