I would recommend you look at the oVirt open source project.
Look at the java code of oVirt engine, and look at the bll module (ovirt-engine/backend/modules/bll) for the authentication code (look at DirectorySearcher.java
) - we do support login in to several kerberos realms.
We have a tool called engine-manage-domains that let you add a "domain user" (which we use mainly for searching users and groups in the added realm) for a domain - for example:
You can add user "aaa" from domain "example.com" which is ActiveDirectory.
This modifies the krb5.conf
defined which is held at /etc/ovirt-engine/krb5.conf
, and which the ovirt-engine uses.
Look at the place in the code where we create a JAAS login object and perform login (we perform explicit login if we don't a valid ticket to the realm).
I think too that cross realm authentication is better solution, but you might face scenarios in which you will not be able to create such trust. For example, at the case of oVirt - it's an open source virtualization management system, and it should not "interfere" or force changing of setups of other systems installed at user's organization.