Common errors in ldb use

Simo Sorce idra at samba.org
Tue Dec 27 09:42:23 GMT 2005


On Tue, 2005-12-27 at 20:14 +1100, Andrew Bartlett wrote:
> I've been thinking about common mistakes I have been making with the LDB
> APIs:
> 
> The first issue is transactions:  We need to have a generic way to
> automatically cancel a transaction from talloc
>  
> However, the issue that prompts this mail is that of mismatches between
> the attributes asked for in a search, and those we enquire of in a
> result.  
> 
> That is, when we do not include (for example) "msDS-KeyVersionNumber" in
> the search attributes, but then enquire of it's value.  This happens
> frequently.

Can you point me at an example, I'm no sure I completely understand the
problem.

> I was wondering if we should add a new member to struct ldb_message, to
> contain the list of attributes requested.  If (in calling
> ldb_msg_find_element()) we ask for an attribute not in that list (and we
> didn't ask for all attributes), we should abort().  

I can't understand the need for such a thing.
In which case you get back a list of attributes that are not requested ?
If that's just for sanity, then you should probably build a function
that check your expectations by passing in a list of attributes and an
ldb_message structure.
I do not see any good reason to make this inside general usage
functions.

Btw, if his happens inside a module, then the module is wrong, the
modules must not violate the search request, and modules that modify the
search requests MUST handle the result and remove attributes that have
not been originally required. See the extended_dn module as an example.

Simo.

-- 
Simo Sorce    -  idra at samba.org
Samba Team    -  http://www.samba.org
Italian Site  -  http://samba.xsec.it



More information about the samba-technical mailing list