add_hook('user_create', array($this, 'lookup_user_name')); } function lookup_user_name($args) { $rcmail = rcmail::get_instance(); if ($addressbook = $rcmail->config->get('new_user_identity_addressbook')) { $match = $rcmail->config->get('new_user_identity_match'); $ldap = $rcmail->get_address_book($addressbook); $ldap->prop['search_fields'] = array($match); $results = $ldap->search($match, $args['user'], TRUE); if (count($results->records) == 1) { $args['user_name'] = $results->records[0]['name']; if (!$args['user_email'] && strpos($results->records[0]['email'], '@')) { $args['user_email'] = idn_to_ascii($results->records[0]['email']); } } } return $args; } } ?>