On 28 Apr 2004, at 19:30, denis.havlik@xxxxxxxxxxx wrote:
Also the async option is only valid in the constructor as it is a per
connection option. You can also call $ldap->async to turn on/off the
connection's async flag. It isn't correct to pass async=>1 in a normal
operation.
Well, I wasn't sure where to put it, so I've actually put it
"everywhere"
(connect/bind/search) in the hope that it wan't do any harm if not
needed.
:-)
It's only in constructor now...
You probably do not want that. With the async option You have to
provide the code to monitor the socket. Just the callback is probably
what you want.
You might want to look at the Net::LDAP::Search man page, in
particular
the
pop_entry() and shift_entry() methods.
Ah, thx.
The only reason to use these in a callback is to save memory. Otherwise
oll messages are kept and still available via $mesg when the search is
complete
Depending on what you're trying to achieve you might also consider
passing a
callback to the search method, which will get called as every search
result
is returned. See the CALLBACKS section of the Net::LDAP man page for
some
details of (oddly enough) callbacks.
Well, I'm browsing trough manpages all the time, and so I tried the
callback method in the meantime (looks nice, would in fact like to use
it), but that doesn't work the way I expected it will.
What did you expect ?
my $KMUsers = $KMLdap->search(filter=>'(uid=*)', scope=>'sub',
base=>$base,
attrs=>'1.1', sizelimit=>10,
callback=>\&myCallback);
print "END\n";
sub myCallback
{
my $mesg = shift;
my $entry = shift;
my $count = $mesg->count;
This is a common mistake. You cannot call ->count in a callback. The
count is not known until the search has completed, in fact calling it
will currently block until it has finished.
There are a few methods that block until completion, I have been
considering have them return undef when called from within a callback.
print "HERE\n";
printf "%5d Found (%s)\n", $count, $entry->dn;
}
I expected to see a lot of "HERE", followed by one "END", and possibly
even some DNs. Reality was different:
END
HERE
That is probably because you passed async to the constructor and you
did not really want to.
Graham.
Hm. So the function exits first, and calls the callback afterwards?
Don't
understand. :-(
help?
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|