[JNDI/LDAP] Intercepting LDAP URLs with initial and referral directory contexts
Osipov, Michael
michael.osipov at siemens.com
Tue Apr 19 13:24:42 UTC 2016
Hi Pavel,
> Any chance these relates to what you are looking for?
>
> "Automatic Discovery of LDAP Servers" [1] and "Manually Following
> Referrals" [2]?
I know both but cannot/refuse to use them.
As for [1]: It suffers from https://bugs.openjdk.java.net/browse/JDK-8149521
plus I can neither lookup for site-specific domain controllers
(_ldap._tcp.SiteName._sites. DnsDomainName.) nor can I provide backups servers
(String[]) if the first one fails.
As for [2]: I don't want to handle referrals manually because I would need
to clone all env properties, construct DirContext myself and manage the open
contexts until I have my result. I would ultimately duplicate the code written
by Sun which simply don't want to. I quick test revealed that the Sun code
just does fine.
Michael
> --------------------------------------------------------------------------
> ------
> [1] http://docs.oracle.com/javase/jndi/tutorial/ldap/connect/create.html
> [2] http://docs.oracle.com/javase/jndi/tutorial/ldap/referral/throw.html
>
> > On 19 Apr 2016, at 11:53, Osipov, Michael <michael.osipov at siemens.com>
> wrote:
> >
> > Hi folks,
> >
> > I am looking for a clean way to intercept/alter LDAP URLs for both
> cases: initial and referrals (follow)
> > before the directory context is created actually.
> > In detail, I need to perform some AD related SRV lookups and replace the
> provided hostname which is actually
> > a naming context with a real hostname.
> >
> > What I have achieved so far but am not really happy with:
> > I have registered an ldapURLContextFactory with Context.URL_PKG_PREFIXES
> where I can swap the URL but
> > this a really ugly solution because initial connections are not routed
> through this factory, only referral
> > ones. Additionally, I have to create a complete Context which my class
> is not willing to do, but merely
> > extends the private class com.sun.jndi.url.ldap.ldapURLContextFactory.
> >
> > My questions are:
> > 1. How can I intercept initial contexts creations too with the same
> ObjectFactory?
> > 2. How do I get rid of the dependency to that private Sun class?
> >
> > Thanks and regards,
> >
> > Michael Osipov
> >
> >
More information about the core-libs-dev
mailing list