[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: search filter for presence of dn

> I am attempting to determine the presence of a DN in LDAP.  I am using the C
> SDK of OpenLDAP 1.2.9.
> I am calling ldap_search as follows:
>   ldap_search_s(lconn,
>                 dn,      // the dn being searched for
>                 LDAP_SCOPE_BASE,
>                 "(objectclass=*)",
>                 0);
> This works fine when the DN is present, but returns an error code
> LDAP_NO_SUCH_OBJECT when the DN is not present.
> My question is:  Is this the intended behaviour, it seems strange to return
> an error code on a valid query.  Is there a better way to do this, or should
> I just test the error code for LDAP_NO_SUCH_OBJECT.
> Thanks in advance,
> Mark

That is exactly how it is supposed to be used.  Any search in which the
base does not exist will return LDAP_NO_SUCH_OBJECT.  A base search as
above, will either fail, or succeed (and return exactly one object in
the result which will be the same as the dn.