On my Linux (CentOS 5.2) server, I have configued OpenLDAP (2.3.43)'s slapd daemon not to listen on TCP for better security, but only on Unix domain sockets instead (SLAPDURLLIST="ldapi:///" in /etc/sysconfig/ldap). I can successfully connect on the command line using "ldapsearch -x -H ldapi://" and LDAP user authentication also works fine this way with Moodle. However, there seems no way to connect via Drupal's LDAP Authentication module:

Going to "Administer -> Site configuration -> LDAP Authentication -> [ Add Server ] -> Server settings" in my Drupal 6.8, there are only the "LDAP Server" and "LDAP Port" settings to specify the LDAP server. So these settings assume an LDAP server is always running as a TCP service. Is there any way to also connect to a sockets listening server?

In Moodle (1.9.3) there is the built-in option "Site Administration -> Users -> Authentication -> LDAP server -> Host URL" which accepts the setting "ldapi://". Is this not possible with Drupal?

Comments

roball’s picture

Category: feature » support
johnbarclay’s picture

I don't have a setup to test this on and I'm not sure if moodle is using the ldap_connect function (
http://us2.php.net/manual/en/function.ldap-connect.php).

When I put
ldapapi:// in the ldap server field and 0 in the port field, it is passed on correctly to the

ldap_connect($this->server, $this->port) function as:

ldap_connect("ldapapi://",0)

1. You could hard code lin 134 of LDAPInterface.php from:

if (!$con = ldap_connect($this->server, $this->port)) {

to

if (!$con = ldap_connect("ldapapi://")) {

for testing purposes. If it works, just comment out the core requiring a port:

lines 343-345 of ldapauth.admin.inc

 // if (!is_numeric($values['port'])) {
 //   form_set_error('port', t('The TCP/IP port must be an integer.'));
 // }
roball’s picture

Yes johnbarclay, Moodle also uses PHP's native ldap_connect() function. On which OS do you have Drupal 6 installed to test? Because there may exist a openldap package for it, for setting up a test case.

I will test your suggestion as soon as I have a stable Internet connection (which I don't have at the moment).

roball’s picture

I now have successfully tested this module's behaviour. It *is* possible, simply by using these Server settings:

LDAP Server: ldapi://
LDAP Port: 0

If the server is listening on ldap://localhost/ (which means it listens on TCP port 389), we could set:

LDAP Server: ldap://localhost/
LDAP Port: 0

Thus, there is no need to change the current code functionality - only the associated documentation should be corrected.

Problem solved :-)

miglius’s picture

Status: Active » Fixed
roball’s picture

Title: No way to connect to an LDAP server listening at "ldapi://"? » Connecting to an LDAP server listening at "ldapi://"

Status: Fixed » Closed (fixed)

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

miglius’s picture

Component: Code » Documentation