Net::LDAP and contextCSN

--Za5zok5IUDjcYzESjtEK8bLlT6I8J5z4y
Content-Type: multipart/mixed; boundary="g51z91HsC4IbXtMJ1sTVEqvG6uJJOeTKr";
 protected-headers="v1"
From: Christian <chris@computersalat.de>
To: perl-ldap@perl.org
Message-ID: <14e5b537-5ed9-ef47-319b-1afc3ac725b4@computersalat.de>
Subject: Net::LDAP and contextCSN

--g51z91HsC4IbXtMJ1sTVEqvG6uJJOeTKr
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Content-Language: de-DE

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 =3D ldap->search( base =3D> $BaseDn, scope =3D> ''base', filter =3D=
>
'*', attrs =3D> 'contextCSN'] );

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

Thank you

--=20

Christian
------------------------------------------------------------
   https://join.worldcommunitygrid.org?recruiterId=3D177038=20
------------------------------------------------------------
           http://www.sc24.de - Sportbekleidung
------------------------------------------------------------



--g51z91HsC4IbXtMJ1sTVEqvG6uJJOeTKr--

--Za5zok5IUDjcYzESjtEK8bLlT6I8J5z4y
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEThvTI4MzF/bFZJIZlrSBLH1fdAkFAl0sk3UACgkQlrSBLH1f
dAlclwf+IO4bODZDP9Wamvt97HRotqVGmJl/I6c794z4vcG6/Qk1GDuX0tTgqJrQ
9zoPsDVpk5X923suJ7ay2U10fP0MEgQ5Yq4DPZeg+AS0NRXz3x5WmHSU8McLANKQ
37z/zgEkPgftbG4s5Qv1+yZc+L2YpMs0dhUDOGbAhDkmUXDyIHXmRIcYP9prH0Vl
Jktj023lzdIrge9o7iWqziA4oDhsgd51IJSmAC/vmadZoOEUtGhvZd15dxsYfSBK
wW6JN/k/XcDu4NEJjritz6iWkB0Sh/fpqTTcjYZoPlq2AgeGAEsL75VkKCcmG5zt
ZyFVi2F1Obljd6M1S3XoBNbGfOU7hg==
=cdqd
-----END PGP SIGNATURE-----

--Za5zok5IUDjcYzESjtEK8bLlT6I8J5z4y--
0
chris
7/15/2019 2:53:41 PM
perl.ldap 1263 articles. 0 followers. Follow

3 Replies
51 Views

Similar Articles

[PageSpeed] 57

--On Monday, July 15, 2019 5:53 PM +0200 Christian <chris@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>
0
quanah
7/15/2019 3:10:21 PM
--------------17AE8FA3AA460491DA3D00BE
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit

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



Am 15.07.2019 um 16:53 schrieb Christian:
> 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
>


--------------17AE8FA3AA460491DA3D00BE
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 8bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hello Christian,</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">I don't know the exact syntax for
      ldapsearch because I haven't used it for ages.<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">filter =&gt; '*' indeed is no valid
      filter.  It is a bit like trying an SQL command like SELECT
      contextCSN FROM $table WHERE *<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">If I remember correctly, you either
      need to omit the filter:<br>
    </div>
    <div class="moz-cite-prefix">
      <div class="moz-cite-prefix">
        <pre class="moz-quote-pre" wrap="">$search = $ldap-&gt;search(
    base   =&gt; $BaseDn,
    scope  =&gt; 'base',
    attrs  =&gt; [ 'contextCSN'],
);
</pre>
      </div>
    </div>
    <div class="moz-cite-prefix">or set on which attribute you search
      for:<br>
    </div>
    <div class="moz-cite-prefix">
      <pre class="moz-quote-pre" wrap="">$search = $ldap-&gt;search(
    base   =&gt; $BaseDn,
    scope  =&gt; 'base',
    filter =&gt; '(contextCSN=*)',
    attrs  =&gt; [ 'contextCSN'],
);
</pre>
    </div>
    <div class="moz-cite-prefix">Also see the examples for search in
      <a class="moz-txt-link-freetext" href="https://metacpan.org/pod/distribution/perl-ldap/lib/Net/LDAP.pod">https://metacpan.org/pod/distribution/perl-ldap/lib/Net/LDAP.pod</a>
      and for the syntax
      <a class="moz-txt-link-freetext" href="https://metacpan.org/pod/distribution/perl-ldap/lib/Net/LDAP/Filter.pod">https://metacpan.org/pod/distribution/perl-ldap/lib/Net/LDAP/Filter.pod</a></div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">BTW: it's better to copy&amp;paste
      code, because the code you gave in your call for help will never
      compile, see the red annotations in your code example.<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Kind regards</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Strat<br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Am 15.07.2019 um 16:53 schrieb
      Christian:<br>
    </div>
    <blockquote type="cite"
      cite="mid:14e5b537-5ed9-ef47-319b-1afc3ac725b4@computersalat.de">
      <pre class="moz-quote-pre" wrap="">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 = <font color="#ff0000">ldap</font>-&gt;search( base =&gt; $BaseDn, scope =&gt; <font color="#ff0000">''base'</font>, filter =&gt;
'*', attrs =&gt; <font color="#ff0000">'contextCSN']</font> );

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

Thank you

</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>

--------------17AE8FA3AA460491DA3D00BE--
0
martin
7/15/2019 9:46:02 PM
--PJyGH9bvHmsrrt2H5BtLUsqnk9SKII2Ht
Content-Type: multipart/mixed; boundary="KsBitxyPEqK8O08niC0gPMQRH80gG04P8";
 protected-headers="v1"
From: Christian <chris@computersalat.de>
To: perl-ldap@perl.org
Message-ID: <533780f8-de38-4766-0710-814e0c2b1471@computersalat.de>
Subject: Re: Net::LDAP and contextCSN
References: <14e5b537-5ed9-ef47-319b-1afc3ac725b4@computersalat.de>
 <77e9ec31-d0d1-a3fa-647f-e9099146e187@fabiani.net>
In-Reply-To: <77e9ec31-d0d1-a3fa-647f-e9099146e187@fabiani.net>

--KsBitxyPEqK8O08niC0gPMQRH80gG04P8
Content-Type: text/plain; charset=utf-8
Content-Language: de-DE
Content-Transfer-Encoding: quoted-printable

Hello Strat,

thank you for your reply.

Am 15.07.19 um 23:46 schrieb Martin Fabiani-Reher:
> Hello Christian,
>=20
> I don't know the exact syntax for ldapsearch because I haven't used it
> for ages.
>=20
> filter =3D> '*' indeed is no valid filter.=C2=A0 It is a bit like tryin=
g an SQL
> command like SELECT contextCSN FROM $table WHERE *
>=20
> 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:
>=20
> $search =3D $ldap->search(
>     base   =3D> $BaseDn,
>     scope  =3D> 'base',
>     filter =3D> '(contextCSN=3D*)',
>     attrs  =3D> [ 'contextCSN'],
> );
This works and in combination with Dales simple Example I got it running
and getting the wanted results. :-)


>=20
> 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 =3D> '(objectClass=3D*)',
or
filter =3D> '(contextCSN=3D*)',

both work.
Regards

--=20

Christian
------------------------------------------------------------
   https://join.worldcommunitygrid.org?recruiterId=3D177038
------------------------------------------------------------
           http://www.sc24.de - Sportbekleidung
------------------------------------------------------------


--KsBitxyPEqK8O08niC0gPMQRH80gG04P8--

--PJyGH9bvHmsrrt2H5BtLUsqnk9SKII2Ht
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEThvTI4MzF/bFZJIZlrSBLH1fdAkFAl0tebEACgkQlrSBLH1f
dAk40Af/VLjvj6zefnekhDAiKYrQdm89U4Mq7FJQeeaYARwwGNDchnyPvjEWk1Tm
iQxmQdDVtqloysdZZ32pRJiWOAI9IEcGOiSdtA01XrSmaRbiVnrOh4LsJ/QdcPD/
bMEArHyFKN/FK+tFgJtImQLsQldhw2XSyvGuydytQ/8RnbGp1lavyHZh4Bj9xHEK
jT1lJ+B9VGE1DcX03d1ADSEI5nggEVs056rMaVYTN/eQGdTtd/Mmo3iwrInycMqg
kbdu8PFAx3RdM2o0kkTc7kllr94wmULWvXRmqirnXQw8bj41DIEh4I1pn8bdRq9m
+PHQxTUsHiE25vyRLPX3mdE1DmEPUA==
=BJC/
-----END PGP SIGNATURE-----

--PJyGH9bvHmsrrt2H5BtLUsqnk9SKII2Ht--
0
chris
7/16/2019 7:15:58 AM
Reply: