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

Re: How to search from inside an overlay (newbie)

José Marco wrote:

Hi everybody. I managed to keep developing til now but I'm desperate today...

 I guess this is easy stuff for people with some experience in OpenLDAP:

I just need to perform a search. I am inside an overlay's response and I need to search for some entries. The question is:

- How do I set the SlapReply rs?
- I guess I need to create an Operation. How do I do that?
- I have to call some search function. I found some searching functions taking an Operation* and a SlapReply* as parameters (like do_search and others) but I don't know which is the one I need.

If you could just drop an example (I guess that it is some 5 lines). I just have to perform a search with a filter I know (and have constructed as a string). Should be something like:

   char *filter = "objectClass=Aclass";
   // SlapReply *rs initialization
   // Operation *op initialization
   // Perform search( op, rs )

Maybe I'm far from the solution...

I would be very pleased if you could help me with this, I'm just going mad jumping from one place in the code to another...

If this message should be sent to another mailing list, just tell me and I'll resend it correctly.

Indeed, this may need some knowledge of OpenLDAP internals to be accomplished correctly. I believe slapd's code and existing overlays provide quite a bunch of examples in many cases. The general rule is that to initialize those structures, from within a function that receives a pointer to an Operation, something like

function( <whatever>, Operation *op, <whatever>)
	Operation o = *op;
	SlapReply r = {0};

	/* ... */

	search(&o, &r);

	/* ... */

	return <whatever>;

is fine, provided you don't modify the original values by reference (i.e. the contents of pointers) but by value (i.e. replace pointers with pointers to data that is private to your overlay).

It's hard to tell what you can or you can't modify, because it depends on the type of operation and on what you need to do.

Hope this helps.


Ing. Pierangelo Masarati
OpenLDAP Core Team

SysNet s.r.l.
via Dossi, 8 - 27100 Pavia - ITALIA
Office:  +39 02 23998309
Mobile:  +39 333 4963172
Email:   pierangelo.masarati@sys-net.it