[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
querry on ldap_search_s()
Placed At :
Hi All,
Will the function ldap_search_s() return LDAP_SUCCESS even when the search
does not match the filter specifed ???
I have pasted below a part of my code and its output
*****************************************************************************************************
printf("filter : %s\n", filter);
printf("basedn : %s\n", basedn);
ret = ldap_search_s(ld, basedn, LDAP_SCOPE_SUBTREE, filter, fields, 0, &res);
ldap_perror(ld, "ldap_search_s:");
free(basedn);
free(filter);
if (ret != LDAP_SUCCESS)
{
*status = -10;
return NULL;
}
msg = ldap_first_entry(ld, res);
ldap_perror(ld, "ldap_firs_entryt:");
ret = ldap_count_entries(ld, msg);
ldap_perror_entries(ld, "ldap_count:");
printf("count : %d\n", ret);
subtree = ldap_get_dn(ld, msg);
ldap_perror(ld, "ldap_get_dn:");
***********************************************************************************************************
output :
filter : (&(objectclass=xyzUser)(uid=not_in_ldap))
basedn : o=xyz
ldap_search:: Success
ldap_first:: Success
ldap_count_entries:: Success
count : 0
ldap_get_dn:: Bad parameter to an ldap routine
*****************************************************************************************************************
Here i have "o=xyz" as the root DN , "ou=south,o=xyz" and "ou=north,o=xyz" as
the subtrees, and then uid's in the object class "xyzUser" under these
subtrees.
Since both ldap_search_s() and ldap_first_entry() returns a success , only way i
can check if a uid exist is by the function ldap_count_entries().
I this the way to do it or am i going wrong somewhere ??
Waiting for replies
Thanks in advance.
Regards
Susanth