开发者

LDAP filter not being considered

开发者 https://www.devze.com 2022-12-22 21:57 出处:网络
I am performing an LDAP search query in C like so; ldap_search_ext_s(ld, BASEDN, SCOPE, FILTER, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res);

I am performing an LDAP search query in C like so;

ldap_search_ext_s(ld, BASEDN, SCOPE, FILTER, attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res);

My search performs fine except when I try to specify FILTER to be; #define FILTER "uid=*", that is, when I try to run a search for all LDAP entries with a uid.

Unfortunately my code just returns the first entry for each result that it finds. So, my code might find 50 results, but will return the first entry 50 times.

Can anyone suspect what 开发者_Python百科I might be doing wrong here?

EDIT: I am stepping through my results like so:

for (msg = ldap_first_message(ld, res); msg != NULL; msg = ldap_next_message(ld, msg))

Any help is really appreciated. Ricky.


How are you stepping through the results? Your code should be something like:

LDAPMessage *entry;

for (entry = ldap_first_entry(ld, res); entry != NULL; entry = ldap_next_entry(ld, entry)
{
    /* Examine "entry" */
}

In particular, make sure you are passing entry to ldap_next_entry, and not res.


Sorry everyone. A friend of mine pointed out that I should be passing msg to the ldap_first_entry commands and the like. This resolved the issue and returned each result individually.

Thanks for all your help. Ricky.


Have you checked that the query works as expected when using, e.g. the command line search tool (assuming you have the OpenLDAP utilities available)?

ldapsearch -b BASEDN '(uid=*)'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号