Summary | Adding entry to LDAP fails due to missing 'sn' |
Queue | Turba |
Queue Version | HEAD |
Type | Bug |
State | Not A Bug |
Priority | 2. Medium |
Owners | |
Requester | ntai (at) smartfruit (dot) com |
Created | 02/15/2007 (6744 days ago) |
Due | |
Updated | 02/15/2007 (6744 days ago) |
Assigned | |
Resolved | 02/15/2007 (6744 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | No |
schema of your LDAP server and of your Turba is entirely up to you.
Make people enter lastname -- There is no corresponding field in the
turba_object sql table.
I'm using PostgresSQL for personal addressbook and LDAP server for
public addressbook, aliasing missing lastname in Turba schema is very
inconvenient.
If I don't automagically generate lastname/sn from "name" in Turba,
Copy/Move command from private to public address book command needs to
ask the last name, which is not present.
I do not see any "lastname" in the "New Contact" form either. If there
were, I wound't be this cranky.
It is indeed that it's up to my setting to use whichever the schema to
use for the LDAP server, however, (a) inetOrgPerson comes with LDAP
server, (b), turba/config/sources.php.dist comes with inetOrgPerson
mentioned in the objectclass.
It's not fair to say that it's up to users to screw up after providing
all of screw-up ingredients.
I did not do anything extraordinally to screw up. I simply followed
the logical path presented by the examples and so forth and somehow
facing the problem.
State ⇒ Not A Bug
schema of your LDAP server and of your Turba is entirely up to you.
State ⇒ Unconfirmed
Priority ⇒ 2. Medium
Type ⇒ Bug
Summary ⇒ Adding entry to LDAP fails due to missing 'sn'
Queue ⇒ Turba
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;
+ }
}