As far as I can tell, the LDAP modules do not provide any easy method to disable LDAP authentication when the module is installed and enabled.

This proves to be difficult trying to automate build tests as the module needs to be disabled when importing or generating users (such as with drush generate-users) when not able to access the LDAP server. If the LDAP module is a dependency on other custom Features then it proves to be very problematic as other functionality then might also be disabled.

Attached is a quick patch which works around this issue. It does not contain an UI changes (I will wait for approval of the idea first) but it does allow the new variable ldap_servers_enabled to be set via drush or in the settings.php file as $conf['ldap_servers_enabled'].

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andrewsuth’s picture

Status: Active » Needs review
seanB’s picture

This is actually something we need as well. I have only 1 remark:
The search() function should return:
* @return
* An array of matching entries->attributes (will have 0
* elements if search returns no results),
* or FALSE on error.

I think we should return an empty array instead of TRUE?

seanB’s picture

sime’s picture

I have some integration tests using mink, the ones that need to log in hang locally when I can't access the LDAP server. I can make them work with:

// Disable ldap on authenitation - good for local dev.
$conf['ldap_user_conf'] = ['drupalAcctProvisionServer' => 0];
grahl’s picture

This might be a dumb question but why can't you disable the LDAP server you configured before you run your tests?

sime’s picture

It's a general pattern you see in many modules. You let the module decide how to remain enabled and not make calls out.

  • grahl committed ee30b15 on 7.x-2.x
    Issue #2459589 by andrewsuth, seanB, sime: LDAP Authentication: provide...
grahl’s picture

Status: Needs review » Fixed

Doing a return directly in search but still trying to connect and bind is not a solution from my perspective, however, since configuration overrides work just fine for this, I've updated install.txt to mention them and provided examples, which solve both reported cases.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.