Re: Net::LDAP and contextCSN

[email protected] (Martin Fabiani-Reher) Mon, 15 Jul 2019 23:46:02 +0200
Newsgroups perl.ldap
Message-ID <[email protected]>
--------------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:[email protected]">
      <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--