The actual security infrastructure items won't be visible inside the webapp. Not only would that be a potential security risk (the app user and the app itself could even have different security connections!), but also it wouldn't be possible in a transparent way. One of the great things about security realms is that you can use a tomcat-users.xml file for
testing even though the production system is LDAP-authenticated.
However, you CAN set up a system where the info you want is inferred based on the user principal name, using that as an argument to an LDAP search.
The example you cited, however, seems to have more to do with database connections. And like security realms, in J(2)EE, database connections are generally best left completely in the hands of the container. You wouldn't (I hope!) get a different connection for each user! For one thing, it places the DBA in the position of having to duplicate the security team's work for each web application user.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.