Bug 1050184 - [GSS] (6.2.x) LDAP: InitialDirContext.search() method doesn't accecpt url included name parameter
Summary: [GSS] (6.2.x) LDAP: InitialDirContext.search() method doesn't accecpt url inc...
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Naming
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
Target Milestone: CR1
: EAP 6.2.1
Assignee: emartins
QA Contact:
Depends On: 1014911
Blocks: eap62-cp01-blockers 1060867
TreeView+ depends on / blocked
Reported: 2014-01-08 20:13 UTC by Derek Horton
Modified: 2018-12-04 16:52 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
This release of JBoss EAP contains a fix to a problem encountered wherein a search of an LDAP server would fail with an exception if the first 'name' field contained a URL and port number. This format is now supported and no longer causes an exception to be thrown.
Clone Of:
Last Closed: 2014-02-24 20:15:16 UTC
Type: Bug

Attachments (Terms of Use)

System ID Priority Status Summary Last Updated
Red Hat Issue Tracker WFLY-2319 Major Closed LDAP Search containing URL - InvalidNameException: ldap:: [LDAP: error code 34 - Invalid root Dn given 2018-03-19 21:54:21 UTC

Description Derek Horton 2014-01-08 20:13:26 UTC
Description of problem:

When trying to use InitialDirContext.search(String name, String filter, SearchControls cons) method to search LDAP server, if the first "name" parameter includes url and port number, an javax.naming.InvalidNameException exception will be thrown. This issue only happens in EAP 6, same source code works fine in either EAP 5 or as standalone Java client.

Version-Release number of selected component (if applicable):

How reproducible:

The source code snippet below can be used to reproduce this issue:

Hashtable env = new Hashtable();
        env.put("java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory");
        env.put("java.naming.security.authentication", "simple");
        env.put("java.naming.ldap.version", "3");
        env.put("java.naming.referral", "ignore");
        env.put("java.naming.ldap.derefAliases", "never");       
        env.put("java.naming.provider.url", "ldap://");
        env.put("java.naming.factory.url.pkgs", "org.jboss.as.naming.interfaces:org.jboss.ejb.client.naming");
       SearchControls ctl = null;
       String attrArr[] = new String[1];
       attrArr[0] = "objectclass";
       ctl  = new SearchControls(2, 0L, 0, attrArr, false, false);
       String base = "ldap://,dc=com";
       String filter = "(uid=sample@sample.com)";         
       NamingEnumeration nenum = null;
       DirContext ictx = null;
            ictx = new InitialDirContext(env);
            nenum = ictx.search(base, filter, ctl);   // <====== issue occurs on this line
            return "SUCCESS";
        catch(NamingException ne1){


Actual results:

Below exception will be thrown:
09:31:57,377 ERROR [stderr] (http-/ javax.naming.InvalidNameException: ldap:: [LDAP: error code 34 - Invalid DN Syntax]; remaining name 'ldap://,dc=com'
09:31:57,377 ERROR [stderr] (http-/ 	at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
09:31:57,378 ERROR [stderr] (http-/ 	at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source)
09:31:57,378 ERROR [stderr] (http-/ 	at com.sun.jndi.ldap.LdapCtx.c_lookup(Unknown Source)
09:31:57,378 ERROR [stderr] (http-/ 	at com.sun.jndi.toolkit.ctx.ComponentContext.c_resolveIntermediate_nns(Unknown Source)
09:31:57,378 ERROR [stderr] (http-/ 	at com.sun.jndi.toolkit.ctx.AtomicContext.c_resolveIntermediate_nns(Unknown Source)

To workaround the issue:
Change the line:
String base = "ldap://,dc=com";

String base = "dc=sample,dc=com";

By removing url part, search() method will work with the name string.

Expected results:

 NamingEnumeration object returned, even if using "ldap://,dc=com" as name parameter.

Additional info:

From the official "The JNDI Tutorial", names with url should be supported.

Comment 1 Anil Saldhana 2014-01-08 20:47:22 UTC
Some one from Naming subsystem should look at this issue.

Comment 2 Derek Horton 2014-01-08 21:23:42 UTC

Comment 3 Scott Mumford 2014-01-20 05:57:15 UTC
Marking for inclusion in 6.2.1 release notes documentation.

Comment 4 Josef Cacek 2014-01-27 15:37:14 UTC
Verified in 6.2.1.CP.CR1.

Comment 5 Ohad Basan 2014-02-02 15:39:41 UTC

where can I get updated rpms with the fix?


Comment 6 JBoss JIRA Server 2014-02-03 19:32:56 UTC
Josef Cacek <jcacek@redhat.com> updated the status of jira WFLY-2319 to Reopened

Comment 7 Ohad Basan 2014-02-05 09:27:33 UTC
why is this bug on "verified" when the wildfly issue in unresolved?
I tested the CR3 rpms and still the rhev automation is failing



Note You need to log in before you can comment on or make changes to this bug.