How to Integrate LDAP to Drupal

Today I have an urgent duty to integrate LDAP authentication to Drupal. Fortunately, ldap_integration module saved my life. Anyway, in order to make it work under Drupal 4.7.0 beta 6, I have to patch a bit regarding _user_authenticated_id(). This function has been replaced by a constant value DRUPAL_AUTHENTICATED_RID.

Index: ldap_integration.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ldap_integration/ldap_integration.module,v
retrieving revision 1.6
diff -u -r1.6 ldap_integration.module
--- ldap_integration.module     26 Jan 2006 16:06:41 -0000      1.6
+++ ldap_integration.module     5 Apr 2006 05:30:06 -0000
@@ -879,7 +879,7 @@
       //      people as externally authentified.
       $dn = _ldap_integration_login2dn("$name$at$server");
       $mail = $ldap->retrieveAttribute($dn, LDAP_EMAIL_ATTRIBUTE);
-      $user = user_save(’’, array(’name’ => "$name$at$server", ’pass’ => $pass, ’mail’ => $mail, ’init’ => $mail, ’status’ => 1, "authname_ldap_integration" => "$name$at$server", ’roles’ => array(_user_authenticated_id()), ’ldap_authentified’ => TRUE, ’ldap_dn’ => $dn));
+      $user = user_save(’’, array(’name’ => "$name$at$server", ’pass’ => $pass, ’mail’ => $mail, ’init’ => $mail, ’status’ => 1, "authname_ldap_integration" => "$name$at$server", ’roles’ => array(DRUPAL_AUTHENTICATED_RID), ’ldap_authentified’ => TRUE, ’ldap_dn’ => $dn));
       watchdog(’user’, t(’New external user: %user using module %module.’, array(’%user’ => theme(’placeholder’, $name .’@’. $server), ’%module’ => theme(’placeholder’, $module))), WATCHDOG_NOTICE, l(t(’edit’), ’user/’. $user->uid .’/edit’));
     }
   }
@@ -921,4 +921,4 @@
   msg($output);
 }
 
-?>
\ No newline at end of file
+?>

The next thing is to configure secret settings in ldap_integration/conf.php. I just modified LDAP_WRITER_USER_DN, LDAP_WRITER_USER_PASS, LDAP_READER_USER_DN, and LDAP_READER_USER_PASS. And then modify configuration to match the LDAP. My LDAP server is OpenLDAP.

  • Organisation is what you really set
  • Server is the hostname
  • Port is 389
  • When logging in, Drupal will look up for the user on: Drupal’s own database. If it fails, will look on the LDAP directory
  • Should Drupal account fields be mapped to LDAP attributes?: Directory or Active Directory system
  • Base DNs: Your DN without the last ou
  • UserName attribute: uid

According to the Base DNs and Organisation, if your DN is "uid=sugree_pha,ou=People,ou=TNGC,ou=ThaiGrid,o=Grid", so that means:

  • Base DNs: ou=Thaigrid,o=Grid
  • Organisation: TNGC

I have not configured groups and roles mapping yet. So, please wait a while.

Technorati Tags: , , , , , , , ,

Post new comment