Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8273385

Resolved hostname via LdapDnsProvider from LDAP context not available

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Any OS (not OS-specific), Java 8 and Java 11.

      A DESCRIPTION OF THE PROBLEM :
      If you have created a LdapDnsProvider which resolves hostnames from an LDAP URL and an exception occurs, there is no way to obtain the actual/real hostname from the NamingException:
      DirContext c = (DirContext) e.getResolvedObj();
      c.getEnvironment()
      java.naming.provider.url in the environment will only contain the original URL, not those resolved by the LdapDnsProvider. There is com.sun.jndi.ldap.domainname which contains the domain name, not a hostname. The internal LdapClient stores the hostname, but is inaccessible.
      If you want to log the exception there is no way to log the actual failed hostname which makes analysis really really hard.

      The RFE is to add the properties: com.sun.jndi.ldap.hostname and/or com.sun.jndi.ldap.address to the environment.
      com.sun.jndi.ldap.hostname: the actual hostname the LDAP connection has been established to.
      com.sun.jndi.ldap.address: the actual address hostname:port the LDAP connection has been established to. LdapDnsProvider may result in different ports as in the original URL.

      This is a non-invasive changes which can be applied to 16, 17, but also 11 and 8. It requires only a few lines of changes in the constructor of LdapCtx.


            aefimov Aleksej Efimov
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: