title: ldap Naming Exception
body: <p>am trying to get the user details from ADAM Active Directory.
  i used the following java code.</p>
  
  <pre><code>import javax.naming.*;
  import javax.naming.directory.*;
  import java.util.Hashtable;
  
  public class SimpleQuery {
  public static void main(String[] args) {
  
              StringBuffer output = new StringBuffer();
      attribute="street";
      query="(&amp;(cn=ldap1))";
  
      try {
          String url = "ldap://172.16.12.178:389/cn=users,dc=sharepoint,dc=com";
          Hashtable env = new Hashtable();
          env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
          env.put(Context.PROVIDER_URL, url);
          DirContext context = new InitialDirContext(env);
  
          String[] attributeFilter = {"cn", "givenName", "SN", "street", "streetAddress", "postalAddress", "postOfficeBox", "l", "st", "postalCode", "c", "telephoneNumber", "homePhone", "mobile", "pager", "mail", "objectCategory", "objectClass", "userAccountControl"};
          SearchControls ctrl = new SearchControls();
          ctrl.setReturningAttributes(attributeFilter);
          ctrl.setSearchScope(SearchControls.SUBTREE_SCOPE);
          NamingEnumeration enumeration = context.search("", query, ctrl);
          while (enumeration.hasMore()) {
              SearchResult result = (SearchResult) enumeration.next();
              Attributes attribs = result.getAttributes();
              NamingEnumeration values = ((BasicAttribute) attribs.get(attribute)).getAll();
              while (values.hasMore()) {
                if (output.length() &gt; 0) {
                  output.append("|");
                }
                output.append(values.next().toString());
              }
          }
  
      } catch (Exception e) {
          System.out.println("Exception : "+e);
          e.printStackTrace();
      }
      System.out.print(output.toString());
  }
  
  public SimpleQuery() {}}
  </code></pre>
  
  <p>and am getting this exception:</p>
  
  <pre><code>javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C09
  06DC, comment: In order to perform this operation a successful bind must be comp
  leted on the connection., data 0, v1db0 ]; remaining name ''
  </code></pre>
  
  <p>Is there any attribute i need to put?.</p>
  
  <p>Please guide me.</p>
  
  <p>Thanks</p>