[jboss-jira] [JBoss JIRA] (WFLY-2319) LDAP Search containing URL - InvalidNameException: ldap:: [LDAP: error code 34 - Invalid root Dn given

RH Bugzilla Integration (JIRA) jira-events at lists.jboss.org
Tue Oct 29 07:25:02 EDT 2013


    [ https://issues.jboss.org/browse/WFLY-2319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12825472#comment-12825472 ] 

RH Bugzilla Integration commented on WFLY-2319:
-----------------------------------------------

emartins at redhat.com made a comment on [bug 1014911|https://bugzilla.redhat.com/show_bug.cgi?id=1014911]

Have you tried to use String base = "dc=sample,dc=com"; ? ldap:// names are to be used with no environment properties map, and the handling of such jndi names is mostly what we are fixing here, so proper names for LdapCtxFactory should work at the moment.

Here is an example of proper usage on Oracle JNDI LDAP docs:

http://docs.oracle.com/javase/jndi/tutorial/basics/directory/src/SearchRetAll.java
                
> LDAP Search containing URL - InvalidNameException: ldap:: [LDAP: error code 34 - Invalid root Dn given
> ------------------------------------------------------------------------------------------------------
>
>                 Key: WFLY-2319
>                 URL: https://issues.jboss.org/browse/WFLY-2319
>             Project: WildFly
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Naming
>    Affects Versions: 8.0.0.Beta1
>            Reporter: Darran Lofthouse
>            Assignee: Eduardo Martins
>             Fix For: 8.0.0.CR1
>
>         Attachments: LdapSearching.tgz
>
>
> The following code: -
> {code}
>         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.provider.url", "ldap://localhost:10389");
>         env.put(InitialDirContext.SECURITY_PRINCIPAL, "uid=admin,ou=system");
>         env.put(InitialDirContext.SECURITY_CREDENTIALS, "secret");
>         SearchControls ctl = null;
>         String attrArr[] = new String[1];
>         attrArr[0] = "sn";
>         ctl = new SearchControls(2, 0L, 0, attrArr, false, false);
>         String base = "ldap://localhost:10389/dc=simple,dc=wildfly,dc=org";
>         String filter = "(uid=UserOne)";
>         NamingEnumeration nenum = null;
>         DirContext ictx = null;
>             ictx = new InitialDirContext(env);
>             nenum = ictx.search(base, filter, ctl);
> {code}
> Results in the following exception: -
> {noquote}
> 13:03:45,598 ERROR [stderr] (default task-1) javax.naming.InvalidNameException: ldap:: [LDAP: error code 34 - Invalid root Dn given : ldap: (0x6C 0x64 0x61 0x70 0x3A ) is invalid]; remaining name 'ldap://localhost:10389/dc=simple,dc=wildfly,dc=org'
> 13:03:45,599 ERROR [stderr] (default task-1) 	at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3025)
> 13:03:45,600 ERROR [stderr] (default task-1) 	at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2840)
> 13:03:45,600 ERROR [stderr] (default task-1) 	at com.sun.jndi.ldap.LdapCtx.c_lookup(LdapCtx.java:1034)
> {noquote}
> Switching to a base that does not begin with a URL and the search works, executing this code outside of WildFly also works.
> The underlying issue is that the default InitialContext implementation contains the following method: -
> {code}
>     protected Context getURLOrDefaultInitCtx(String name)
>         throws NamingException {
>         if (NamingManager.hasInitialContextFactoryBuilder()) {
>             return getDefaultInitCtx();
>         }
>         String scheme = getURLScheme(name);
>         if (scheme != null) {
>             Context ctx = NamingManager.getURLContext(scheme, myProps);
>             if (ctx != null) {
>                 return ctx;
>             }
>         }
>         return getDefaultInitCtx();
>     }
> {code}
> As the naming subsystem has registered a InitialContextFactoryBuilder this code will never fall down to the scheme specific section.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list