Is it possible to make the ldap_integration module to run a simple external/stand-alone perl script (or any other shell script for that matter) right after the user succesfully update their profile (those that map to LDAP attribute). For example, my user can change their email address via Drupal and the 'mail' attribute will be changed as well. Now, everytime a user do this, I want it to run a script that basically read the LDAP content and do an update to another database which is not related to Drupal at all.
If it's possible, can you show me where to change? A sample code will really helps ;)

Thanks in advance.

Rgds,
Hendra

Comments

pablobm’s picture

Er... maybe you should write a Drupal module implementing the _user hook.

But probably you will just do with a quick&dirty solution, so just edit this function on the code accordingly:

function ldap_integration_user_update_ldap_attributes(&$edit, $user) {
  global $ldap;

  $ldap->disconnect();
  if(!$ldap->connect(LDAP_WRITER_USER_DN, LDAP_WRITER_USER_PASS)) {
    watchdog('user', "User update: user $user->name's data could not be updated in the LDAP directory");
    return;
  }

  $writeout = array();
  $editables = variable_get('ldap_useredit_attributes', array());

  foreach ($edit as $edit_attr => $edit_val) {
    // Preventing a POST data injection: we check allowance to write value.
    if (array_search($edit_attr, $editables) !== FALSE) {
      $writeout[$edit_attr] = $edit_val;
      $edit[$edit_attr] = null;
    }
  }

  // The $writeout variable contains the LDAP name//value pairs of the attributes being updated
  if ($writeout) {
    $ldap->writeAttributes($user->ldap_dn, $writeout);
  }

  $ldap->disconnect();
}

The exact location for your code is within the if ($writeout) { (...) } statement.

pablobm’s picture

Assigned: Unassigned » pablobm
Status: Active » Needs review
kreaper’s picture

Assigned: pablobm » kreaper
kreaper’s picture

Category: support » feature
Status: Needs review » Postponed

This should be a feature request

kreaper’s picture

Status: Postponed » Closed (fixed)