I've finally found the solution myself, but it's not elegant: the plugin hook is not there and i ended up modifying list_identities in program/includes/rcube_user.php with some ldap lookup code that outputs a 'fake' sql result array. The hook that would be needed here should give the chance to modify the behavior of list_identities().
The modification I made looks up the groups of which a user is a member of, and creates identities according to that, prepended with an empty identity string.
Here's the code:
function list_identities($sql_add = '')
{
$result = $this->_cb_make_fakequery($this->data['username']);
return $result;
}
function _cb_findcn($_cb_ldap_server, $ou, $cb_id)
{
$con = ldap_connect($_cb_ldap_server);
$search = ldap_search($con, "ou=".$ou.",dc=example,dc=com","(|(uid=".$cb_id."))",array("cn"));
$search_result = ldap_get_entries($con, $search);
$cnresult = $search_result[0]['cn'][0];
return $cnresult;
}
function _cb_findgroups($_cb_ldap_server, $ou, $cb_id)
{
$con = ldap_connect($_cb_ldap_server);
$search_result = ldap_search($con,"ou=".$ou.",dc=example,dc=com","(|(uid=".$cb_id.")(memberUid=".$cb_id."))",array("cn"));
$ldap_result = ldap_get_entries($con,$search_result);
for($i = 0; $i <= $ldap_result['count']-1; $i++)
{
$ids[] = $ldap_result[$i]['cn'][0];
}
return $ids;
}
function _cb_make_fakequery($uid)
{
$fakequery = array(array('name' => '', 'standard' => 1, 'del' => 0, 'email' => '', 'identity_id' => '', 'signature' => '', 'html_signature' => 0));
foreach($this->_cb_findgroups("localhost", "Group",$uid) as $gid)
{
$domain = "example.com";
if($gid == $uid)
{
$fullname = $this->_cb_findcn("localhost", "People", $gid);
$fakequery[] = array('name' => $fullname, 'standard' => 0, 'del' => 0, 'email' => $gid.'@'.$domain, 'identity_id' => $gid, 'signature' => '', 'html_signature' => 0);
}
else
{
$fullname = $this->_cb_findcn("localhost", "Groups", $gid);
$fakequery[] = array('name' => $fullname, 'standard' => 0, 'del' => 0, 'email' => $gid.'@'.$domain, 'identity_id' => $gid, 'signature' => '', 'html_signature' => 0);
}
}
return $fakequery;
}