Wilmer Jaramillo M.
2007-Jul-30 02:48 UTC
[Fedora-directory-users] Unlimited line width for ldapsearch
I found that ../shared/bin/ldasearch only show a output of 76 chars per line, and manual page not described how be longer the output, i want set the line-width used to implement filter in long strings ''OU'' in perl scripts. Also i found a very simple patch for ldapsearch of openldap tools in: http://www.openldap.org/lists/openldap-bugs/199912/msg00099.html openldap it does not have support still. Probably some method of Net::LDAP can do it, I''m investigating a module or regex that can help me in this, any suggestion? thanks. -- Wilmer Jaramillo M. GPG Key Fingerprint = 0666 D0D3 24CE 8935 9C24 BBF1 87DD BEA2 A4B2 1E8A
Howard Wilkinson
2007-Jul-30 07:26 UTC
Re: [Fedora-directory-users] Unlimited line width for ldapsearch
Wilmer Jaramillo M. wrote:> I found that ../shared/bin/ldasearch only show a output of 76 chars > per line, and manual page not described how be longer the output, i > want set the line-width used to implement filter in long strings ''OU'' > in perl scripts. Also i found a very simple patch for ldapsearch of > openldap tools in: > http://www.openldap.org/lists/openldap-bugs/199912/msg00099.html > openldap it does not have support still. > > Probably some method of Net::LDAP can do it, I''m investigating a > module or regex that can help me in this, any suggestion? thanks. > > > >Take a look at Net::LDAP::LDIF an option to new is called ''wrap'' which is normally set to 78 (one space, 76 printing characters, and the newline for continuation lines) this should give you what you want. -- Howard Wilkinson Phone: +44(20)76907075 Coherent Technology Limited Fax: 23 Northampton Square, Mobile: +44(7980)639379 United Kingdom, EC1V 0HL Email: howard@cohtech.com
Wilmer Jaramillo M.
2007-Jul-30 18:26 UTC
Re: [Fedora-directory-users] Unlimited line width for ldapsearch
On 7/30/07, Howard Wilkinson <howard@cohtech.com> wrote:> > Wilmer Jaramillo M. wrote: > I found that ../shared/bin/ldasearch only show a output of 76 chars > per line, and manual page not described how be longer the output, i > want set the line-width used to implement filter in long strings ''OU'' > in perl scripts. Also i found a very simple patch for ldapsearch of > openldap tools in: > http://www.openldap.org/lists/openldap-bugs/199912/msg00099.html > openldap it does not have support still. > > Probably some method of Net::LDAP can do it, I''m investigating a > module or regex that can help me in this, any suggestion? thanks. > > Take a look at Net::LDAP::LDIF an option to new is called ''wrap'' which is normally set to 78 (one space, 76 printing characters, and the newline for continuation lines) this should give you what you want. >I''m looking to replace the following query to a Windows ADS for a Perl sintax because the output is limited for line-width: my $ldapsearch = "(ldapsearch - x - H ldap: To //$adserver - D "to $aduser" - w $adpass - s sub - b "$baseDN"" (cn=*) ''| grep - i "ou=" | cut - d, - F2 | grep - v - i "CN= " | uniq)` I want search in the directory for all entries firts level OrganizationalUnit (ou) just now I''m using Mozilla::LDAP::Conn with very good results, nevertheless, the searches are very slow, anyway that just do right what I need, according to man: use Mozilla::LDAP::Conn; .... $conn = new Mozilla::LDAP::Conn($adserver,$adport,$aduser,$adpass); die "LDAP not connect $adserver" unless ($conn); &org_unit($baseDN); exit(0); sub org_unit() { my ($entry, $dn, $scope, $filter, $dn) = ""; my (@ouDN, @attrs) = (); @attrs = ( "ou" ); $scope = "sub"; $filter = "(ou=*)"; # Busca en el directorio las entradas ous $entry = $conn->search($baseDN, $scope, $filter, 0, @attrs); $cld = $conn->getLD(); $res = $conn->getRes(); $count = Mozilla::LDAP::API::ldap_count_entries($cld, $res); while ($entry) { # Coloca en un array cada entrada DN $ouDN = $entry->getDN(); push (@ouDN,$dn); print "$dn\n"; $entry = $conn->nextEntry(); } foreach $dn (@ouDNS) { &org_unit($dn) } } thanks for all. -- Wilmer Jaramillo M. GPG Key Fingerprint = 0666 D0D3 24CE 8935 9C24 BBF1 87DD BEA2 A4B2 1E8A
Howard Wilkinson
2007-Jul-30 18:34 UTC
Re: [Fedora-directory-users] Unlimited line width for ldapsearch
Wilmer Jaramillo M. wrote:> On 7/30/07, Howard Wilkinson <howard@cohtech.com> wrote: > >> Wilmer Jaramillo M. wrote: >> I found that ../shared/bin/ldasearch only show a output of 76 chars >> per line, and manual page not described how be longer the output, i >> want set the line-width used to implement filter in long strings ''OU'' >> in perl scripts. Also i found a very simple patch for ldapsearch of >> openldap tools in: >> http://www.openldap.org/lists/openldap-bugs/199912/msg00099.html >> openldap it does not have support still. >> >> Probably some method of Net::LDAP can do it, I''m investigating a >> module or regex that can help me in this, any suggestion? thanks. >> >> Take a look at Net::LDAP::LDIF an option to new is called ''wrap'' which is normally set to 78 (one space, 76 printing characters, and the newline for continuation lines) this should give you what you want. >> >> > > I''m looking to replace the following query to a Windows ADS for a > Perl sintax because the output is limited for line-width: > my $ldapsearch = "(ldapsearch - x - H ldap: To //$adserver - D "to > $aduser" - w $adpass - s sub - b "$baseDN"" (cn=*) ''| grep - i "ou=" | > cut - d, - F2 | grep - v - i "CN= " | uniq)` > > I want search in the directory for all entries firts level > OrganizationalUnit (ou) just now I''m using Mozilla::LDAP::Conn with > very good results, nevertheless, the searches are very slow, anyway > that just do right what I need, according to man: > > use Mozilla::LDAP::Conn; > .... > $conn = new Mozilla::LDAP::Conn($adserver,$adport,$aduser,$adpass); > die "LDAP not connect $adserver" unless ($conn); > > &org_unit($baseDN); > exit(0); > > sub org_unit() > { > my ($entry, $dn, $scope, $filter, $dn) = ""; > my (@ouDN, @attrs) = (); > > @attrs = ( "ou" ); > $scope = "sub"; > $filter = "(ou=*)"; > > # Busca en el directorio las entradas ous > $entry = $conn->search($baseDN, $scope, $filter, 0, @attrs); > $cld = $conn->getLD(); > $res = $conn->getRes(); > $count = Mozilla::LDAP::API::ldap_count_entries($cld, $res); > while ($entry) { > # Coloca en un array cada entrada DN > $ouDN = $entry->getDN(); > push (@ouDN,$dn); > print "$dn\n"; > $entry = $conn->nextEntry(); > } > foreach $dn (@ouDNS) > { > &org_unit($dn) > } > } > > > thanks for all. >You should use the Net::LDAP (perl-ldap) package. Make sure you use page mode access (pages are ~1000 entries for Windows 2000 and ~1500 for Windows 2003) and process each record in a call back. If you set the line wrap in the Net::LDAP::LDIF object you use to write the output you should get the results you want. I have production code using this technology that will process over 120,000 records in less than 15 minutes from a moderately loaded Active Directory. So this should be good enough for what you want. -- Howard Wilkinson Phone: +44(20)76907075 Coherent Technology Limited Fax: 23 Northampton Square, Mobile: +44(7980)639379 United Kingdom, EC1V 0HL Email: howard@cohtech.com
Richard Megginson
2007-Jul-30 18:44 UTC
Re: [Fedora-directory-users] Unlimited line width for ldapsearch
Wilmer Jaramillo M. wrote:> On 7/30/07, Howard Wilkinson <howard@cohtech.com> wrote: > >> Wilmer Jaramillo M. wrote: >> I found that ../shared/bin/ldasearch only show a output of 76 chars >> per line, and manual page not described how be longer the output, i >> want set the line-width used to implement filter in long strings ''OU'' >> in perl scripts. Also i found a very simple patch for ldapsearch of >> openldap tools in: >> http://www.openldap.org/lists/openldap-bugs/199912/msg00099.html >> openldap it does not have support still. >> >> Probably some method of Net::LDAP can do it, I''m investigating a >> module or regex that can help me in this, any suggestion? thanks. >> >> Take a look at Net::LDAP::LDIF an option to new is called ''wrap'' which is normally set to 78 (one space, 76 printing characters, and the newline for continuation lines) this should give you what you want. >> >> > > I''m looking to replace the following query to a Windows ADS for a > Perl sintax because the output is limited for line-width: > my $ldapsearch = "(ldapsearch - x - H ldap: To //$adserver - D "to > $aduser" - w $adpass - s sub - b "$baseDN"" (cn=*) ''| grep - i "ou=" | > cut - d, - F2 | grep - v - i "CN= " | uniq)` >If you use the ldapsearch bundled with Fedora DS (cd /opt/fedora-ds/shared/bin ; ./ldapsearch) rather than openldap /usr/bin/ldapsearch, you can use the -T option, which disables line wrapping, making it easier to pass the output to scripts such as grep/sed/awk/perl without using a separate LDIF parser. The command line options are very similar, just omit the -x.> I want search in the directory for all entries firts level > OrganizationalUnit (ou) just now I''m using Mozilla::LDAP::Conn with > very good results, nevertheless, the searches are very slow, anyway > that just do right what I need, according to man: > > use Mozilla::LDAP::Conn; > .... > $conn = new Mozilla::LDAP::Conn($adserver,$adport,$aduser,$adpass); > die "LDAP not connect $adserver" unless ($conn); > > &org_unit($baseDN); > exit(0); > > sub org_unit() > { > my ($entry, $dn, $scope, $filter, $dn) = ""; > my (@ouDN, @attrs) = (); > > @attrs = ( "ou" ); > $scope = "sub"; > $filter = "(ou=*)"; > > # Busca en el directorio las entradas ous > $entry = $conn->search($baseDN, $scope, $filter, 0, @attrs); > $cld = $conn->getLD(); > $res = $conn->getRes(); > $count = Mozilla::LDAP::API::ldap_count_entries($cld, $res); > while ($entry) { > # Coloca en un array cada entrada DN > $ouDN = $entry->getDN(); > push (@ouDN,$dn); > print "$dn\n"; > $entry = $conn->nextEntry(); > } > foreach $dn (@ouDNS) > { > &org_unit($dn) > } > } > > > thanks for all. >
Wilmer Jaramillo M.
2007-Jul-30 20:20 UTC
Re: [Fedora-directory-users] Unlimited line width for ldapsearch
On 7/30/07, Richard Megginson <rmeggins@redhat.com> wrote:> Wilmer Jaramillo M. wrote: > > On 7/30/07, Howard Wilkinson <howard@cohtech.com> wrote: > > > >> Wilmer Jaramillo M. wrote: > >> I found that ../shared/bin/ldasearch only show a output of 76 chars > >> per line, and manual page not described how be longer the output, i > >> want set the line-width used to implement filter in long strings ''OU'' > >> in perl scripts. Also i found a very simple patch for ldapsearch of > >> openldap tools in: > >> http://www.openldap.org/lists/openldap-bugs/199912/msg00099.html > >> openldap it does not have support still. > >> > >> Probably some method of Net::LDAP can do it, I''m investigating a > >> module or regex that can help me in this, any suggestion? thanks. > >> > >> Take a look at Net::LDAP::LDIF an option to new is called ''wrap'' which is normally set to 78 (one space, 76 printing characters, and the newline for continuation lines) this should give you what you want. > >> > >> > > > > I''m looking to replace the following query to a Windows ADS for a > > Perl sintax because the output is limited for line-width: > > my $ldapsearch = "(ldapsearch - x - H ldap: To //$adserver - D "to > > $aduser" - w $adpass - s sub - b "$baseDN"" (cn=*) ''| grep - i "ou=" | > > cut - d, - F2 | grep - v - i "CN= " | uniq)` > > > If you use the ldapsearch bundled with Fedora DS (cd > /opt/fedora-ds/shared/bin ; ./ldapsearch) rather than openldap > /usr/bin/ldapsearch, you can use the -T option, which disables line > wrapping, making it easier to pass the output to scripts such as > grep/sed/awk/perl without using a separate LDIF parser. The command > line options are very similar, just omit the -x.Excelent, it also now working for me. Thanks Richard and Howard. -- Wilmer Jaramillo M. GPG Key Fingerprint = 0666 D0D3 24CE 8935 9C24 BBF1 87DD BEA2 A4B2 1E8A