title: LDAP search base DN not working
body: <p>I'm trying to perform an LDAP search into many different OUs that are located at the root of the directory.</p>
  
  <p>Context initialization:</p>
  
  <pre><code>Hashtable&lt;String, String&gt; env = new Hashtable&lt;String, String&gt;();
  env.put(Context.SECURITY_AUTHENTICATION, "simple");
  env.put(Context.SECURITY_CREDENTIALS, "somePassword");
  env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
  env.put(Context.SECURITY_PRINCIPAL, "MYDOMAIN\\\\myUsername");
  env.put(Context.PROVIDER_URL, "ldap://myLdapServer:389");
  searchControls = new SearchControls();
  searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE);
  ctx = new InitialDirContext(env);
  </code></pre>
  
  <p>So for searching an user I call</p>
  
  <pre><code>ctx.search("OU=OrgUnitOne,DC=mysite,DC=com", "(sAMAccountName=someUserName)", searchControls)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>ctx.search("OU=OrgUnitTwo,DC=mysite,DC=com", "(sAMAccountName=someUserName)", searchControls)
  </code></pre>
  
  <p>and either works fine. But since I want to search into all of OUs in the root of DA, I have to use another baseDN for the search, which I've failed to find. I've tried the following but none seems to work...</p>
  
  <p><strong>Without OU:</strong></p>
  
  <pre><code>ctx.search("DC=mysite,DC=com", "(sAMAccountName=someUserName)", searchControls)
  //output:
  //javax.naming.PartialResultException: Unprocessed Continuation Reference(s); remaining name 'DC=mysite,DC=com'
  </code></pre>
  
  <p><strong>Empty <code>searchBase</code> string:</strong></p>
  
  <pre><code>ctx.search("", "(sAMAccountName=someUserName)", searchControls)
  //output:
  //javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-031001E5, problem 2001 (NO_OBJECT), data 0, best match of:'']; remaining name ''
  </code></pre>
  
  <p><strong>Desperate wildcard *</strong></p>
  
  <pre><code>ctx.search("OU=\*,DC=mysite,DC=com", "(sAMAccountName=someUserName)", searchControls)
  //output:
  //javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-0310020A, problem 2001 (NO_OBJECT), data 0, best match of:'DC=mysite,DC=com']; remaining name 'OU=*,DC=mysite,DC=com'
  </code></pre>
  
  <p><strong>Desperate wildcard %</strong></p>
  
  <pre><code>ctx.search("OU=%,DC=mysite,DC=com", "(sAMAccountName=someUserName)", searchControls)
  //output:
  //javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-0310020A, problem 2001 (NO_OBJECT), data 0, best match of:'DC=mysite,DC=com']; remaining name 'OU=%,DC=mysite,DC=com'
  </code></pre>
  
  <p><strong>Desperate OR operator |</strong></p>
  
  <pre><code>ctx.search("OU=OrgUnitOne|OrgUnitTwo,DC=mysite,DC=com", "(sAMAccountName=someUserName)", searchControls)
  //output:
  //javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-0310020A, problem 2001 (NO_OBJECT), data 0, best match of:'DC=mysite,DC=com'];    
  </code></pre>
  
  <p>remaining name <code>'OU=OrgUnitOne|OrgUnitTwo,DC=mysite,DC=com'</code></p>
  
  <p>Is there a way to achieve this search over all the root OUs?</p>