Handle LDAP Referral Exceptions in Java 8

Last updated 2 months ago

Learn how to cope with a bug in Java 8

LightbulbWhat you'll learn

  • Know about the Java 9 LDAP bug

Person reading a bookPrerequisites

  • LDAP Integration

WristwatchTime matters

Reading time: 5 minutes

Person in front of a laptopShould I read this?

This guide is for Developers.

Due to a bug in the JNDI implementation in Java 8 the CoreMedia LDAP integration cannot correctly cope with referrals.

The problem shows in exceptions like this:

2016-03-01 16:24:23 [ERROR] com.coremedia.ldap.LdapUserProvider - Exception while serving com.coremedia.ldap.ad.ActiveDirectoryUserProvider#getUsers: java.util.Vector cannot be cast to java.lang.String
 java.lang.ClassCastException: java.util.Vector cannot be cast to java.lang.String
 at com.sun.jndi.ldap.LdapReferralException.getNextReferral(LdapReferralException.java:241) ~[na:1.8.0_65]
 at com.sun.jndi.ldap.LdapReferralException.skipReferral(LdapReferralException.java:201) ~[na:1.8.0_65]
 at com.coremedia.ldap.impl.LdapConnector.ldapSearch(LdapConnector.java:335) ~[coremedia-ldap-7.1.11-5.jar:7.1.11-5]

Workaround for com.coremedia.ldap.basedns

If you use Active Directory with trust relationships, you can only use DNs underneath the DC level in com.coremedia.ldap.basedns.

For instance, it crashes with the following settings:

DC=example,DC=org

But it works with:

CN=Users,DC=example,DC=org

To define more than one base distinguished name (DN) just list them semicolon separated:

com.coremedia.ldap.basedns=CN=Users,DC=example,DC=org;CN=Users,DC=com,DC=de
Copyright © 2025 CoreMedia GmbH, CoreMedia Corporation. All Rights Reserved.
Loading...