Bug 1032227 - [EAP 6.1.1 one-off] LDAP: InitialDirContext.search() method doesn't accecpt url included name parameter
[EAP 6.1.1 one-off] LDAP: InitialDirContext.search() method doesn't accecpt u...
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Naming (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: One-off release
Assigned To: Derek Horton
Depends On:
  Show dependency treegraph
Reported: 2013-11-19 13:15 EST by Derek Horton
Modified: 2014-09-02 09:18 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2014-09-02 09:18:25 EDT
Type: Support Patch
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
patched jars (667.32 KB, patch)
2013-11-19 13:37 EST, Derek Horton
no flags Details | Diff

  None (edit)
Description Derek Horton 2013-11-19 13:15:39 EST
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)
Comment 1 Derek Horton 2013-11-19 13:37:29 EST
Created attachment 826238 [details]
patched jars
Comment 2 Derek Horton 2013-11-19 13:42:55 EST
Fix has been committe to branch:

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