Bug 1050184

Summary: [GSS] (6.2.x) LDAP: InitialDirContext.search() method doesn't accecpt url included name parameter
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Derek Horton <dehort>
Component: NamingAssignee: emartins
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: asaldhan, bmaxwell, cdewolf, jawilson, jcacek, myarboro, obasan, smumford
Target Milestone: CR1   
Target Release: EAP 6.2.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-02-24 20:15:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1014911    
Bug Blocks: 1027004, 1060867    

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://192.168.0.1:389");
        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://192.168.0.1:389/dc=sample,dc=com";
       String filter = "(uid=sample)";         
              
       NamingEnumeration nenum = null;
       DirContext ictx = null;
              
       try{
            ictx = new InitialDirContext(env);
            nenum = ictx.search(base, filter, ctl);   // <====== issue occurs on this line
            
            return "SUCCESS";
        }
        catch(NamingException ne1){
            ne1.printStackTrace();            
        }

=============================================================

Actual results:

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



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

To
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://192.168.0.1:389/dc=sample,dc=com" as name parameter.


Additional info:

From the official "The JNDI Tutorial", names with url should be supported.
http://docs.oracle.com/javase/jndi/tutorial/ldap/misc/url.html

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
PR:
https://github.com/jbossas/jboss-eap/pull/765

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
hello,

where can I get updated rpms with the fix?

thanks!

Comment 6 JBoss JIRA Server 2014-02-03 19:32:56 UTC
Josef Cacek <jcacek> 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
http://jenkins-ci.eng.lab.tlv.redhat.com/view/0%20Unstable%203.3/job/rhevm_3.3_automation_infra_one_host_restapi_mixed_nfs_sdk_factory/101/consoleFull

http://download.devel.redhat.com/devel/candidates/JBEAP/JBEAP-6.2.1.CP.CR3/rpms/

Thanks