Recently upgrade an existing instance to 1.35 from 1.31. Had been using the original LDAPAuthentication app. Can authenticate successfully without TLS, but not after turning on. Trying to hit an AD server.
When I run the debug test (php extensions/LDAPProvider/maintenance/ShowUserInfo.php --domain YourDomain --username SomeUser
), I get this error stack:
MWException from line 139 of /var/lib/mediawiki-1.35.0/extensions/LDAPProvider/src/Client.php: Could not start TLS! #0 /var/lib/mediawiki-1.35.0/extensions/LDAPProvider/src/Client.php(90): MediaWiki\Extension\LDAPProvider\Client->maybeStartTLS() #1 /var/lib/mediawiki-1.35.0/extensions/LDAPProvider/src/Client.php(229): MediaWiki\Extension\LDAPProvider\Client->init() #2 /var/lib/mediawiki-1.35.0/extensions/LDAPProvider/maintenance/ShowUserInfo.php(49): MediaWiki\Extension\LDAPProvider\Client->getUserInfo() #3 /var/lib/mediawiki-1.35.0/maintenance/doMaintenance.php(107): MediaWiki\Extension\LDAPProvider\Maintenance\ShowUserInfo->execute() #4 /var/lib/mediawiki-1.35.0/extensions/LDAPProvider/maintenance/ShowUserInfo.php(72): require_once('/var/lib/mediaw...') #5 {main}
Here's my ldap.json, which for now I keep in the main MediaWiki folder:
{ "lc": { "connection": { "server": "lc.luther.edu", "user": "CN=hdwiki,OU=Vendor,DC=lc,DC=luther,DC=edu", "pass": "***secret***", "port": 1389, "enctype": "tls", "options": { "LDAP_OPT_DEREF": 1 }, "basedn": "DC=lc, DC=luther, DC=edu", "userbasedn": "DC=lc, DC=luther, DC=edu", "groupbasedn": "OU=Groups,DC=lc, DC=luther, DC=edu", "searchattribute": "samaccountname", "usernameattribute": "samaccountname", "realnameattribute": "cn", "emailattribute": "mail", "grouprequest":"MediaWiki\\Extension\\LDAPProvider\\UserGroupsRequest\\UserMemberOf::factory", "presearchusernamemodifiers": [ "spacestounderscores", "lowercase" ] }, "userinfo": [], "authorization": [], "groupsync": { "mapping": { "bureaucrat": "CN=Help_Desk_Managers,OU=Groups,DC=lc, DC=luther, DC=edu" } } } }
Here's the relevant portion of my LocalSettings.php:
error_reporting( -1 ); //debugging. Comment out when in production ini_set( 'display_errors', 1 ); //debugging. Comment out when in production $wgDebugLogGroups['PluggableAuth'] = $wgDebugLogGroups['LDAP'] = $wgDebugLogGroups['MediaWiki\\Extension\\LDAPProvider\\Client'] = $wgDebugLogGroups['LDAPAuthentication2'] = $wgDebugLogGroups['LDAPAuthorization'] = '/tmp/LDAP.log'; . . . $wgGroupPermissions['*']['autocreateaccount'] = true; // Load LDAP Config from JSON $ldapJsonFile = "$IP/ldap.json"; $ldapConfig = false; if (is_file($ldapJsonFile) && is_dir("$IP/extensions/LDAPProvider")) { $testJson = @json_decode(file_get_contents($ldapJsonFile),true); if (is_array($testJson)) { $ldapConfig = true; } else { error_log("Found invalid JSON in file: $IP/ldap.json"); } } // Activate Extension if ( $ldapConfig ) { wfLoadExtension( 'PluggableAuth' ); wfLoadExtension( 'LDAPProvider' ); wfLoadExtension( 'LDAPAuthentication2' ); wfLoadExtension( 'LDAPAuthorization' ); $LDAPProviderDomainConfigs = $ldapJsonFile; $wgPluggableAuth_ButtonLabel = "Log In"; $LDAPAuthentication2AllowLocalLogin = true; }
Error logs at /tmp/LDAP.log look like:
2020-11-24 16:51:11 wiki hdwiki_test: ldap_connect( $hostname = 'ldap://lc.luther.edu:1389', $port = 389 ); 2020-11-24 16:51:11 wiki hdwiki_test: # __METHOD__ returns Resource id #773 2020-11-24 16:51:11 wiki hdwiki_test: Setting LDAP_OPT_PROTOCOL_VERSION to 3 2020-11-24 16:51:11 wiki hdwiki_test: ldap_set_option( $linkID, $option = 17, $newval = 3 ); 2020-11-24 16:51:11 wiki hdwiki_test: # returns 1 2020-11-24 16:51:11 wiki hdwiki_test: Setting LDAP_OPT_REFERRALS to 0 2020-11-24 16:51:11 wiki hdwiki_test: ldap_set_option( $linkID, $option = 8, $newval = 0 ); 2020-11-24 16:51:11 wiki hdwiki_test: # returns 1 2020-11-24 16:51:11 wiki hdwiki_test: Setting LDAP_OPT_DEREF to 1 2020-11-24 16:51:11 wiki hdwiki_test: ldap_set_option( $linkID, $option = 2, $newval = 1 ); 2020-11-24 16:51:11 wiki hdwiki_test: # returns 1 2020-11-24 16:51:11 wiki hdwiki_test: ldap_start_tls( $linkID );
We thought it was odd that first line of the last error code uses one port for $hostname and then another in the $port. We tried not specifying the port in the ldap.json file, same result.
I have php7.4-ldap installed.
Thanks to anyone who read this far. :)