LDAPSEARCH in C

Hi all,

I've been searching for ldapsearch function these few days. Still I couldn't found the solution.

I would like to translate this query

ldapsearch -x -LLL -h new_IP -p new_Port -D "cn=jw" -w "dummy" -b
"id=2311,o=WC,c=jp" -s sub

to ldap_search_ext_s() function in C program.

Any idea how to do it?

Below is my attempt but to no avail:

char		*attrs[] = {"Name", NULL};
tmax.tv_sec = 10;
tmax.tv_usec = 0;
LDAPMessage     *res = NULL
rc = ldap_search_ext_s(ld, "o=WC,c=jp", LDAP_SCOPE_SUBTREE, "(objectclass=*)", attrs, 0, NULL, NULL, &tmax, 1, &res); 

PS: I am newbie in LDAP. Hope you guys could help and intro some good source for me to read more about LDAP for beginner. Thanks