5 * Populates a new user's default identity from LDAP on their first visit.
7 * This plugin requires that a working public_ldap directory be configured.
10 * @author Kris Steinhoff
12 * Example configuration:
14 * // The id of the address book to use to automatically set a new
15 * // user's full name in their new identity. (This should be an
16 * // string, which refers to the $rcmail_config['ldap_public'] array.)
17 * $rcmail_config['new_user_identity_addressbook'] = 'People';
19 * // When automatically setting a new users's full name in their
20 * // new identity, match the user's login name against this field.
21 * $rcmail_config['new_user_identity_match'] = 'uid';
23 * // Use the value in this field to automatically set a new users's
24 * // full name in their new identity.
25 * $rcmail_config['new_user_identity_field'] = 'name';
27 class new_user_identity extends rcube_plugin
31 $this->add_hook('create_user', array($this, 'lookup_user_name'));
34 function lookup_user_name($args)
36 $rcmail = rcmail::get_instance();
37 if ($addressbook = $rcmail->config->get('new_user_identity_addressbook')) {
38 $match = $rcmail->config->get('new_user_identity_match');
39 $ldap = $rcmail->get_address_book($addressbook);
40 $ldap->prop['search_fields'] = array($match);
41 $results = $ldap->search($match, $args['user'], TRUE);
42 if (count($results->records) == 1) {
43 $args['user_name'] = $results->records[0][$rcmail->config->get('new_user_identity_field')];