Getting httpauth to work with ldap_integration module
chrisyates - April 30, 2009 - 19:28
| Project: | HTTP authentication |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | chrisyates |
| Status: | needs review |
Description
I found that because the ldap_integration module (ldapauth) bypasses the Drupal authentication system to do its dirty work, httpauth wouldn't work with LDAP users.
Here's a patch that lets it work by calling ldapauth_login_validate. It's hackish and applied to httpauth rather than the source of the problem, but httpauth is much less complex and brittle.
// Allow authentication via LDAP
if (function_exists('ldapauth_login_validate')) {
require_once('includes/common.inc');
require_once('includes/unicode.inc');
require_once('modules/user/user.module');
require_once(drupal_get_path('module', 'ldapauth') .'/ldap_integration/LDAPInterface.php');
$form_state = array('values' => array('name' => $name, 'pass' => $pass));
ldapauth_login_validate(NULL, $form_state);
}-c
--
Christian Yates
Mars Space Flight Facility
Arizona State University / NASA
| Attachment | Size |
|---|---|
| ldap_integration.patch | 1.01 KB |

#1
Here's an updated patch for the latest ldap_integration (6.x-1.0-beta1) module:
// Allow authentication via LDAP
drupal_load('module', 'ldapauth');
if (function_exists('ldapauth_authenticate')) {
require_once('includes/common.inc');
require_once('includes/unicode.inc');
require_once('includes/form.inc');
drupal_load('module', 'user');
require_once(drupal_get_path('module', 'ldapauth') .'/includes/LDAPInterface.inc');
$form_state = array('values' => array('name' => $name, 'pass' => $pass));
ldapauth_authenticate($form_state['values']);
}