Discussion:
Net::LDAP and contextCSN
(too old to reply)
Christian
2019-07-15 14:53:41 UTC
Permalink
Hi,

could need some help.

I want to do with Net::LDAP what ldapsearch is doing with:
ldapsearch -x -LLL -s base contextCSN

with Net::LDAP I am struggeling ... tried the following:

$search = ldap->search( base => $BaseDn, scope => ''base', filter =>
'*', attrs => 'contextCSN'] );

This results in Bad filter.
From man page of ldapsearch there is no filter defined ... so is this
possible with Net::LDAP ?

Thank you
--
Christian
------------------------------------------------------------
https://join.worldcommunitygrid.org?recruiterId=177038
------------------------------------------------------------
http://www.sc24.de - Sportbekleidung
------------------------------------------------------------
Quanah Gibson-Mount
2019-07-15 15:10:21 UTC
Permalink
Post by Christian
Hi,
could need some help.
ldapsearch -x -LLL -s base contextCSN
$search = ldap->search( base => $BaseDn, scope => ''base', filter =>
'*', attrs => 'contextCSN'] );
This results in Bad filter.
From man page of ldapsearch there is no filter defined ... so is this
possible with Net::LDAP ?
The default filter (if not specified) is "(objectClass=*)".

You may also find this script I wrote for contextCSN monitoring of interest:

<https://github.com/Zimbra/zm-ldap-utilities/blob/develop/src/libexec/zmreplchk>

Regards,
Quanah


--

Quanah Gibson-Mount
Product Architect
Symas Corporation
Packaged, certified, and supported LDAP solutions powered by OpenLDAP:
<http://www.symas.com>
Martin Fabiani-Reher
2019-07-15 21:46:02 UTC
Permalink
Hello Christian,

I don't know the exact syntax for ldapsearch because I haven't used it
for ages.

filter => '*' indeed is no valid filter.  It is a bit like trying an SQL
command like SELECT contextCSN FROM $table WHERE *

If I remember correctly, you either need to omit the filter:

$search = $ldap->search(
base => $BaseDn,
scope => 'base',
attrs => [ 'contextCSN'],
);

or set on which attribute you search for:

$search = $ldap->search(
base => $BaseDn,
scope => 'base',
filter => '(contextCSN=*)',
attrs => [ 'contextCSN'],
);

Also see the examples for search in
https://metacpan.org/pod/distribution/perl-ldap/lib/Net/LDAP.pod and for
the syntax
https://metacpan.org/pod/distribution/perl-ldap/lib/Net/LDAP/Filter.pod

BTW: it's better to copy&paste code, because the code you gave in your
call for help will never compile, see the red annotations in your code
example.

Kind regards

Strat
Post by Christian
Hi,
could need some help.
ldapsearch -x -LLL -s base contextCSN
$search =ldap->search( base => $BaseDn, scope =>''base', filter =>
'*', attrs =>'contextCSN'] );
This results in Bad filter.
From man page of ldapsearch there is no filter defined ... so is this
possible with Net::LDAP ?
Thank you
Christian
2019-07-16 07:15:58 UTC
Permalink
Hello Strat,

thank you for your reply.
Post by Martin Fabiani-Reher
Hello Christian,
I don't know the exact syntax for ldapsearch because I haven't used it
for ages.
filter => '*' indeed is no valid filter.  It is a bit like trying an SQL
command like SELECT contextCSN FROM $table WHERE *
Now I know omitting is not correct and will result in 'Bad Filter' ...
Post by Martin Fabiani-Reher
$search = $ldap->search(
base => $BaseDn,
scope => 'base',
filter => '(contextCSN=*)',
attrs => [ 'contextCSN'],
);
This works and in combination with Dales simple Example I got it running
and getting the wanted results. :-)
Post by Martin Fabiani-Reher
BTW: it's better to copy&paste code, because the code you gave in your
call for help will never compile, see the red annotations in your code
example.
I fully agree, but at that moment I wasn't able to copy&paste ...
hence the typos.

I just wanted to show up the 'filter' problem.
I need to define a valid filter:
filter => '(objectClass=*)',
or
filter => '(contextCSN=*)',

both work.
Regards
--
Christian
------------------------------------------------------------
https://join.worldcommunitygrid.org?recruiterId=177038
------------------------------------------------------------
http://www.sc24.de - Sportbekleidung
------------------------------------------------------------
Loading...