I have a functioning LDAP server. I added another LDAP server and to test the second configuration I disabled the first LDAP server on the server listing page. When I attempt a login I get the following crash report:

Fatal error: Call to a member function connect() on a non-object in /opt/acquia-drupal-7.10.10/sites/all/modules/ldap/ldap_authentication/ldap_authentication.inc on line 213

The problem is that in the $auth_conf->servers list, the disabled server is listed as myserver->false, instead of having a valid object. But the value of FALSE is never handled so the call to $ldap_server->connect() is an improper lookup.

Comments

johnbarclay’s picture

Version: 7.x-1.0-beta5 » 7.x-1.x-dev

Be sure to test with 7.x-1.x-dev. If this is still in it, should be an easy fix.

resplin’s picture

I see the same behaviour in version 7.x-1.x-dev. The problematic test is on line 220.

resplin’s picture

After further testing, I think it is because the server is disabled on the ldap_servers page, but remains enabled on the authentication page.

johnbarclay’s picture

Assigned: Unassigned » johnbarclay
Status: Active » Needs work

A simple fix is the following, but the best solution is implement a hook such as hook_ldap_server_updated() so all the ldap modules can act on changes in ldap server configurations as well as when they are disabled. Otherwise ldap_servers would need to be aware of how other modules were using ldap servers. So I'm marking this as needs work and assigning it to myself.

  foreach ($auth_conf->servers as $sid => $ldap_server) {
+    if ($ldap_server == FALSE) {
+      continue;
+    }
    $watchdog_tokens['%sid'] = $sid;
    $watchdog_tokens['%bind_method'] = $ldap_server->bind_method;
johnbarclay’s picture

Title: Authentication: crash when server is disabled » Authentication: warn user when deleting or disabling ldap server in use
Category: bug » task

I implemented a hook_ldap_server_in_use() function so modules using an ldap server can throw validation errors when an ldap server is disabled or deleted. I've implemeneted in ldap_authorization and ldap_authorization and will push out next dev that I push out.

I'm changing this to a task/feature because it needs to be implemented in ldap_feeds, ldap_query, and ldap_views also.

johnbarclay’s picture

Title: Authentication: warn user when deleting or disabling ldap server in use » LDAP *: warn user when deleting or disabling ldap server in use
johnbarclay’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

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