Net::LDAP and contextCSN

4 views
Skip to first unread message

Christian

unread,
Jul 15, 2019, 11:15:03 AM7/15/19
to perl...@perl.org
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
------------------------------------------------------------


signature.asc

Quanah Gibson-Mount

unread,
Jul 15, 2019, 11:30:03 AM7/15/19
to Christian, perl...@perl.org
--On Monday, July 15, 2019 5:53 PM +0200 Christian <ch...@computersalat.de>
wrote:

> 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 ?

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

unread,
Jul 15, 2019, 6:00:03 PM7/15/19
to Christian, perl...@perl.org
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'],
);

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

Christian

unread,
Jul 16, 2019, 3:30:03 AM7/16/19
to perl...@perl.org
Hello Strat,

thank you for your reply.

Am 15.07.19 um 23:46 schrieb 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 *
>
> If I remember correctly, you either need to omit the filter:
Now I know omitting is not correct and will result in 'Bad Filter' ...


> or set on which attribute you search for:
>
> $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. :-)


>
> 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
signature.asc
Reply all
Reply to author
Forward
0 new messages