Thomas Bruederli thomas@roundcube.net wrote:
I suggest to use the 'login_after' hook to verify/update a user's identities on login. That hook is also available in 0.9.5 so don't worry about that.
So in 'login_after' for example, you have access to the user object with its identities like this:
$user = rcmail::get_instance()->user; foreach ($user->list_identities() as $identity) { // check and update here }
Thank you again. After gathering info on the available methods for the user object from rcube_user.php I was able to come up with the following solution:
function updateuser($args)
{
$rcmail = rcmail::get_instance();
$user = $rcmail->user;
$identity = $user->get_identity();
$username = $user->get_username();
if ($this->init_ldap()) {
$results = $this->ldap->search('*', $username, true);
if (count($results->records) == 1) {
$identity['name'] = is_array($results->records[0]['name']) ? $results->records[0]['name'][0] : $results->records[0]['name'];
$identity['email'] = is_array($results->records[0]['email']) ? $results->records[0]['email'][0] : $results->records[0]['email'];
}
}
$user->update_identity($identity['identity_id'],$identity);
}
The LDAP functions have been ripped from the new_user_identity plugin (thanks Kris Steinhoff) and are identical, I just changed the config-string to "update_user_addressbook" and "update_user_match".
Maybe this functionality can be incorporated into the new_user_identity plugin and make it configurable if the admin wants further automatic updates to the identity of a user after the initial creation.
Grüße, Sven.