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"><<a href=3D"mailto:[email protected]" target=3D"_blank">clem= [email protected]</a>></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->search(<br></span>=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 base=C2=A0 =3D> $ad_user,<br>=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 scope =3D> "base",<br>=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 filter =3D> "(objectclass=3D*)= ",<span class=3D""><br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 attr= =3D> ['mail'],<br>=C2=A0=C2=A0=C2=A0 );<br><br>=C2=A0=C2=A0=C2= =A0 $search_ad->code && die "error on search ad: $@: "= . $search_ad->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->get_value('mail');<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'm afraid. Now it'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--