ldb error codes

Andrew Bartlett abartlet at samba.org
Mon Oct 31 04:50:49 GMT 2005

On Mon, 2005-10-31 at 11:58 +1100, tridge at samba.org wrote:
> Simo (and other interested parties),
> I've just been discussing ldb error codes a bit with Andrew
> Bartlett and wanted to get your opinion on how to fix it. 
> As you know, the current situation is a bit of a mess. When I first
> wrote ldb I screwed up by paying very little attention to error
> codes. We were able to recover OK for most ldb calls, as we just
> defined the return value as being a LDB_ERR* value, or LDB_SUCCESS. We
> still haven't fixed all the places that need to set these values, but
> at least the major ones are fixed.
> The tricky one is ldb_search(). In the ldap API equivalent
> ldap_search_s() returns an error code and then uses functions like
> ldap_count_messages() to count the replies.  Our ldb_search() function
> returns a message count directly, which leaves no room for an error
> code.
> So I have a few possible proposals for fixing this:
>  1) change the sign of the LDB_ERR* values, and make all functions
>     then return a ldb error value. For ldb_search() if the value is >=
>     0 then its a search count, if its < 0 then its an error code. Not
>     pretty, but requires very little code modification.
>  2) change ldb_search() to only return a error code, and add a
>     ldb_count_messages() function. This requires changing all existing
>     calls to ldb_search(). We'd also have to ensure that all backends
>     NULL terminate the result list, as otherwise ldb_count_messages()
>     would not be possible to implemenet.

This is what I prefer, but it is work...

>  3) we could have a ldb_errorcode() function that returns the last
>     error code. 

This is my least preferred option, but is certainly easy to do.

Andrew Bartlett

Andrew Bartlett                                http://samba.org/~abartlet/
Samba Developer, SuSE Labs, Novell Inc.        http://suse.de
Authentication Developer, Samba Team           http://samba.org
Student Network Administrator, Hawker College  http://hawkerc.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/samba-technical/attachments/20051031/731849f8/attachment.bin

More information about the samba-technical mailing list