[Tickets #4998] Adding entry to LDAP fails due to missing 'sn'
bugs@bugs.horde.org
bugs at bugs.horde.org
Wed Feb 14 17:03:31 PST 2007
DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.
Ticket URL: http://bugs.horde.org/ticket/?id=4998
-----------------------------------------------------------------------
Ticket | 4998
Created By | ntai at smartfruit.com
Summary | Adding entry to LDAP fails due to missing 'sn'
Queue | Turba
Version | HEAD
Type | Bug
State | Unconfirmed
Priority | 2. Medium
Owners |
-----------------------------------------------------------------------
ntai at smartfruit.com (2007-02-14 17:03) wrote:
When adding an entry through LDAP driver to openldap hosted shared contact,
it fails due to
ldap_add: Object class violation (65)
additional info: object class 'inetOrgPerson' requires attribute 'sn'
Apparently, the schema I'm using wants to have 'sn' in attributes.
Although the turba/config/sources.php mentions "lastname" -> 'sn' in its
mapping, there is no "lastname" defined in original Turba database.
So, the 'sn' is never given to ldap.
I changed the turba/lib/Driver/ldap.php to give 'sn' a value so that,
add/update operation succeeds.
This is working for me but I don't know enough about Turba.
Index: ldap.php
===================================================================
RCS file: /repository/turba/lib/Driver/ldap.php,v
retrieving revision 1.87
diff -c -r1.87 ldap.php
*** ldap.php 4 Jan 2007 05:08:59 -0000 1.87
--- ldap.php 15 Feb 2007 00:59:01 -0000
***************
*** 247,252 ****
--- 247,253 ----
/* Don't add empty attributes. */
$attributes = array_filter($attributes, array($this,
'_emptyAttributeFilter'));
+ $this->_fixup_sn($attributes);
/* If a required attribute doesn't exist, add a dummy
* value. */
***************
*** 346,351 ****
--- 347,353 ----
unset($attributes[String::lower($object_key)]);
$this->_encodeAttributes($attributes);
$attributes = array_filter($attributes, array($this,
'_emptyAttributeFilter'));
+ $this->_fixup_sn($attributes);
/* Modify objectclass if old one is outdated. */
$attributes['objectclass'] =
array_unique(array_map('strtolower', array_merge($info['objectclass'],
$this->_params['objectclass'])));
***************
*** 749,752 ****
--- 751,769 ----
return $dn;
}
+
+
+ /**
+ * _fixup_sn() patches up the 'sn' for LDAP entry.
+ *
+ */
+ function _fixup_sn(&$attributes)
+ {
+ $name = $attributes['cn'];
+ $lastname = Turba::guessLastname($name);
+ if (empty($lastname))
+ $attributes['sn'] = $name;
+ else
+ $attributes['sn'] = $lastname;
+ }
}
More information about the bugs
mailing list