title: ldap_search_ext_s: No such object error
body: <p>How get info about people after connecting anonymously to server.</p>
  
  <p>I am searching uid=barbara to anonymously binded ldap server as follow,</p>
  
  <p>I get error,</p>
  
  <pre><code>LDAP initialize successful.
  Set LDAPv3 client version.
  LDAP connection successful.
  ldap_search_ext_s: No such object
  </code></pre>
  
  <p>if i chnage 
  char *FIND_DN  = " ou=Users,dc=example,dc=com";</p>
  
  <p>rc = ldap_simple_bind_s(ld,root_dn ,root_pw);
  It works fine.<br>
  code below:</p>
  
  <pre><code>int main(int argc, char**argv) 
  {
   LDAP *ld;
   int desired_version = LDAP_VERSION3;
   char *ldap_host     = "localhost";
   char *root_dn       = "cn=Manager, dc=example,dc=com";
   char *root_pw       = "secret";
   char *FIND_DN  = "dc=example, dc=com";
  
   LDAPMessage  *result, *e;
   BerElement   *ber;
   char         *a;
   char         **vals;
   int          i, rc;
  
   ldap_initialize( &amp;ld, ldap_host );
   printf("LDAP initialize successful.\n");
  
   rc = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &amp;desired_version);
   if ( rc != LDAP_SUCCESS ) {
      perror( "ldap_set_option failed" );
      exit(EXIT_FAILURE);
   } else {
      printf("Set LDAPv3 client version.\n");
   }
  
   rc = ldap_simple_bind_s(ld,NULL ,NULL);
   if ( rc != LDAP_SUCCESS ) {
      fprintf(stderr, "ldap_simple_bind_s: %s\n", ldap_err2string(rc));
      exit(EXIT_FAILURE);
   } else {
      printf("LDAP connection successful.\n");
   }
  
   if ( ( rc = ldap_search_ext_s( ld, FIND_DN, LDAP_SCOPE_SUBTREE,
                                  "(uid=barbara)",NULL,0,NULL,NULL,NULL,
                                  LDAP_NO_LIMIT, &amp;result ) ) != LDAP_SUCCESS ) {
  
       fprintf(stderr, "ldap_search_ext_s: %s\n", ldap_err2string(rc));
       ldap_unbind( ld );
       return( 1 );
   }
   ldap_msgfree( result );
   ldap_unbind( ld );
  
   return( 0 );
  }
  </code></pre>
  
  <p>On ldapsearch command ,i get </p>
  
  <pre>
  Enter LDAP Password:
  
  # Users, example.com
  
  dn: ou=Users,dc=example,dc=com
  
  ou: Users
  
  description: Example.Com Users 
  
  objectClass: organizationalUnit
  
  # matt, Users, example.com
  
  dn: uid=matt,ou=Users,dc=example,dc=com
  
  ou: Users
  
  uid: matt
  
  cn: Matt Butcher
  
  sn: Butcher
  
  givenName: Matt
  
  givenName: Matthew
  
  displayName: Matt Butcher
  
  title: Systems Integrator
  
  description: Systems Integration and IT for Example.Com
  
  employeeType: Employee
  
  departmentNumber: 001
  
  employeeNumber: 001-08-98
  
  mail: mbutcher@example.com
  
  mail: matt@example.com
  
  roomNumber: 301
  
  telephoneNumber: +1 555 555 4321
  
  mobile: +1 555 555 6789
  
  st: Illinois
  
  l: Chicago
  
  street: 1234 Cicero Ave.
  
  homePhone: +1 555 555 9876
  
  homePostalAddress: 1234 home street $ Chicago, IL $ 60699-1234
  
  userPassword:: c2VjcmV0
  
  preferredLanguage: en-us,en-gb
  
  objectClass: person
  
  objectClass: organizationalPerson
  
  objectClass: inetOrgPerson
  
  # barbara, Users, example.com
  
  dn: uid=barbara,ou=Users,dc=example,dc=com
  
  ou: Users
  
  uid: barbara
  
  sn: Jensen
  
  cn: Barbara Jensen
  
  givenName: Barbara
  
  displayName: Barbara Jensen
  
  mail: barbara@example.com
  
  userPassword:: c2VjcmV0
  
  objectClass: person
  
  objectClass: organizationalPerson
  
  objectClass: inetOrgPerson
  
  
  # search result
  
  search: 2
  
  result: 0 Success
  
  # numResponses: 4
  
  # numEntries: 3
  </pre>