I was wondering if there was a way to configure an LDAP connection within an EJB much like you would configure a DataSource? I would like to be able to do LDAP searches, but I would expect that the connection would be defined in the deployment descriptor for the bean.
For example, some simple code in an arbitrary EJB method:
Since I can only declare resource manager types of DataSource, QueueConnection, TopicConnection, Session or URL in the deployment descriptor, yet I WANT a DirContext, I am unsure how to do this.
I am guessing that perhaps I can create a resource-ref of type java.net.URL and simply set the URL to "ldap://myldapserver.com". However, I'm not sure that a lookup to the URL would even return a DirContext object. Furthermore, typically an LDAP context needs to have its INITIAL_CONTEXT_FACTORY set to something, such as "com.sun.jndi.ldap.LdapCtxFactory". Do I set this to my InitialContext from my container?
In the above example, I would like to be able to do something like:
I have heard of configuring LDAP realms for the server, but I am hoping to discover a more "portable" approach as discussed above.