1

We're trying to push a Civi contact's data into an LDAP data store using the Civi Drupal entity module and the Drupal ldap module. That part works fine. If a user updates their contact card using a Civi user profile form, the changes are immediately pushed into ldap.

But when we update the same contact using the Rest API, the changes are not synced into ldap and we dont know why. (The REST API call does successfully update the civi contact card however.) We suspect its because some specific Drupal function is not being called and are wondering if it is a bug. The closest I have been able to find is hook_user_update. Reading the documentation, we believe it isn't called by the Rest API but is called by Civi Profile form. We're not sure about this.

What can we do to ensure that the Civi entity module successfully updates our LDAP store when called using the REST interface?

1 Answer 1

1

We believe the bug may be caused by the Drupal hook model which expects to receive Drupal form data which the Civi API is not capable of invoking since, of course, it does not use forms. Shimming the data would have been messy and clunky so in the end we hooked directly into the LDAP module using CiviCRM's edit hooks. Like this:

function ldap_user_civicrm_post($op, $objectName, $objectId, &$objectRef) {
  if ($op=="edit") {
    try {
      $cms_user_id = civicrm_api3('UFMatch', 'getvalue', array(
        'return' => "uf_id",
        'contact_id' => $objectId,
      ));
      if ($cms_user_id) {
        $account = user_load($cms_user_id);

        $ldap_user_conf = ldap_user_conf();

        $bool_result = $ldap_user_conf->synchToLdapEntry($account);
        if ($bool_result) {
          ldap_user_ldap_provision_semaphore('synch', 'set', $account->name);
        }
      }
    } catch (Exception $e) {

    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.