I want to get the data from default basedn.
I have set the basedn in ldap.conf like this:

ldap.conf
----------------------------------------------------
BASE dc=example,dc=com
#URI ldap://ldap.example.com ldap://ldap-master.example.com:666

#SIZELIMIT 12
#TIMELIMIT 15
#DEREF never

TLS_CACERTDIR /etc/openldap/certs
----------------------------------------------------

and the command "ldapsearch" is worked:

----------------------------------------------------
[root]#ldapsearch -x "uid=ldst3000000001"
# extended LDIF
#
# LDAPv3
# base <dc=example,dc=com> (default) with scope subtree
# filter: uid=ldst3000000001
# requesting: ALL
#

# ldst3000000001, people, example.com
dn: uid=ldst3000000001,ou=people,dc=example,dc=com
uid: ldst3000000001
......

# search reference
ref: ldap://192.168.1.102:389/ou=people2,dc=example,dc=com??sub

# search result
search: 2
result: 0 Success

# numResponses: 3
# numEntries: 1
# numReferences: 1
[root]#
----------------------------------------------------

but when i use ldap_search_s to get the data, got the error :
ldap_search_s: No such object (32)


source:
----------------------------------------------------
LDAP *ld;
if (ldap_initialize(&ld, LDAP_SERVER))
{
perror( "ldap_initialize" );
exit(1);
}

if (ldap_simple_bind_s(ld, LDAP_DN, LDAP_PASSWD) != LDAP_SUCCESS)
{
ldap_perror( ld, "ldap_simple_bind_s" );
exit(1);
}

iResult = ldap_search_s(ld, NULL, LDAP_SCOPE_SUBTREE, filter, NULL, 0, &res);
if (iResult != LDAP_SUCCESS)
{
ldap_perror( ld, "ldap_search_s" );
exit(1);
}
----------------------------------------------------

Am I missing any other configuration before ldap_search_s?
Is anything needs to be configured in ldap.conf & slapd.conf ?

Can anyone kindly help on this ?

Regards,
hua0638