We had the following error when trying to create a user in LDAP from Drupal:

Failed to save the user to LDAP. Object class violation

The LDAP log showed the following:

May  8 21:12:00 valkyrie slapd[1055]: Entry (cn=test10,dc=local): object class 'inetOrgPerson' requires attribute 'sn'

Turns out the default OpenLDAP schema *requires* the "sn" field to be populated. now maybe we screwed up something in our config, but here's at least a module to remove the error:


/**
 * @file
 * Mail simple_ldap_user_sn module file.
 */

/**
 * implements hook_simple_ldap_user_to_ldap_alter()
 */
function simple_ldap_user_sn_simple_ldap_user_to_ldap_alter($ldap_user, $drupal_user) {
  // sn is required for inetOrgPerson
  if (!isset($ldap_user->sn)) {
    $ldap_user->sn = $ldap_user->dn;
  }
}
name = Simple LDAP User SN override
description = Populates the SN field for the Simple LDAP user module
package = LDAP
dependencies[] = simple_ldap
core = 7.x

Comments

ergonlogic’s picture

Issue summary: View changes
anarcat’s picture

Status: Active » Closed (works as designed)

oops. it seems we don't actually need to code anything, this can be overriden in the settings.php, to quote the README (duh):

$conf['simple_ldap_user_attribute_map'] = array(

  // Generic example.
  array(
    'drupal' => '#drupal-user-field-machine-name',
    'ldap' => 'ldap-attribute',
  ),

  // First name example.
  array(
    'drupal' => '#field_first_name',
    'ldap' => 'givenName',
  ),

  // Last name example.
  array(
    'drupal' => '#field_last_name',
    'ldap' => 'sn',
  ),
// [...]
);

much simpler...