Patch for LDAP Integration module in Drupal 4.7

According to the previous post, the patch is not complete for all functions. I found a problem according to attributes mapping. The attributes changed in Drupal are not synchronized to LDAP because of missing some options in administer interface. So below is the new patch.

cvs diff: Diffing .
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     8 Apr 2006 12:31:58 -0000
@@ -130,6 +130,11 @@
   $options_login_process = array(
       LDAP_FIRST_DRUPAL => t(’Drupal\’s own database. If it fails, will look on the LDAP directory’),
       LDAP_FIRST_LDAP => t(’LDAP directory only’));
+  // Attribute mapping
+  $options_attribute_mapping = array(
+      LDAP_MAP_ATTRIBUTES => t(’Map all attributes’),
+      LDAP_MAP_ONLY_LOST_PASSWORDS => t(’Map only lost passwords’),
+      LDAP_MAP_NOTHING => t(’Map nothing’));
 
   $form[’ldap_login_process’] = array(
     ’#type’ => ’radios’,
@@ -879,7 +884,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 +926,4 @@
   msg($output);
 }
 
-?>
\ No newline at end of file
+?>

Well, next step is to modify mappings in conf.php. There are 2 modifications. The first one is ldap_drupal_mappings.

$GLOBALS[’ldap_drupal_mappings’] = array(
  ’mail’ => ’mail’,
  ’userPassword’ => ’pass’,
);

The second one is ldap_attributes.

$GLOBALS[’ldap_attributes’] = array(
  ’givenName’     => array(’text’, ’textfield’, t(’First Name’), 64, 64),
  ’userPassword’  => array(’pass’, ’password’, t(’Password’), 64, 64),
  ’sn’            => array(’text’, ’textfield’, t(’Last Name’), 64, 64), //aka Surname
  ’cn’            => array(’text’, ’textfield’, t(’Common Name’), 64, 64),
  ’mail’          => array(’mailto’, ’textfield’, t(’Email’), 64, 64, ’’),
  ’loginShell’            => array(’text’, ’textfield’, t(’Login shell’), 64, 64),
);

That’s all for modification. The next big thing is to choose Map all attributes in admin/settings/ldap_integration/login_procedure. That is the missing one in the original code.

Technorati Tags: , , , , , , , , ,

Post new comment