Re: slow AD ldap query or bad filter/algorithm?

Natxo Asenjo <[email protected]> Fri, 11 Dec 2015 12:54:18 +0100
Newsgroups gmane.comp.lang.perl.modules.ldap
Message-ID <CAHBEJzXeJQC-GMWNWcH4hcU59vOsK2rG5RkoNisj9E2vgYgOOQ@mail.gmail.com>
--001a113e6c50bd2f1b05269dfb27
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

hi,

On Fri, Dec 11, 2015 at 12:15 PM, Cl=C3=A9ment OUDOT <[email protected]>
wrote:

> You should do a search directly on the member DN (with scope base) instea=
d
> of requestind the suffix in sub _get_ad_user_mail :
>
> sub _get_ad_user_mail {
>     my ($ad_user) =3D @_;
>     my $search_ad =3D $ad_ldap->search(
>         base  =3D> $ad_user,
>         scope =3D> "base",
>         filter =3D> "(objectclass=3D*)",
>         attr =3D> ['mail'],
>     );
>
>     $search_ad->code && die "error on search ad: $@: " . $search_ad->erro=
r;
>     for my $entry ( $search_ad->entries ) {
>         my $ad_user_mail =3D $entry->get_value('mail');
>         return $ad_user_mail;
>     }
> }
>
>
mmm, not very much difference, I'm afraid. Now it's even a bit slower:
2m45sec. Could be network bound (behind a vpn connection now).

Maybe I need to get a list of users and save its info in another hash, that
could be much faster than making lots of queries per group.
--=20
--
Groeten,
natxo

--001a113e6c50bd2f1b05269dfb27
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">hi,<br><div><div class=3D"gmail_extra"><br><div class=3D"g=
mail_quote">On Fri, Dec 11, 2015 at 12:15 PM, Cl=C3=A9ment OUDOT <span dir=
=3D"ltr">&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">clem=
[email protected]</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><d=
iv dir=3D"ltr">You should do a search directly on the member DN (with scope=
 base) instead of requestind the suffix in sub  _get_ad_user_mail :<br><div=
 class=3D"gmail_extra"><div class=3D"gmail_quote"><div><span class=3D""><br=
>sub _get_ad_user_mail {<br>=C2=A0=C2=A0=C2=A0 my ($ad_user) =3D @_;<br>=C2=
=A0=C2=A0=C2=A0 my $search_ad =3D $ad_ldap-&gt;search(<br></span>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 base=C2=A0 =3D&gt; $ad_user,<br>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 scope =3D&gt; &quot;base&quot;,<br>=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 filter =3D&gt; &quot;(objectclass=3D*)=
&quot;,<span class=3D""><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 attr=
 =3D&gt; [&#39;mail&#39;],<br>=C2=A0=C2=A0=C2=A0 );<br><br>=C2=A0=C2=A0=C2=
=A0 $search_ad-&gt;code &amp;&amp; die &quot;error on search ad: $@: &quot;=
 . $search_ad-&gt;error;<br>=C2=A0=C2=A0=C2=A0 for my $entry ( $search_ad-&=
gt;entries ) {<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 my $ad_user_ma=
il =3D $entry-&gt;get_value(&#39;mail&#39;);<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0 return $ad_user_mail;<br>=C2=A0=C2=A0=C2=A0 }<br>}<br></spa=
n></div><br></div></div></div></blockquote><div><br></div><div>mmm, not ver=
y much difference, I&#39;m afraid. Now it&#39;s even a bit slower: 2m45sec.=
 Could be network bound (behind a vpn connection now). <br></div></div><br>=
</div><div class=3D"gmail_extra">Maybe I need to get a list of users and sa=
ve its info in another hash, that could be much faster than making lots of =
queries per group.<br></div><div class=3D"gmail_extra">-- <br><div class=3D=
"gmail_signature">--<br>Groeten,<br>natxo</div>
</div></div></div>

--001a113e6c50bd2f1b05269dfb27--