Hi, I have an LDIF file containing hundreds of entries however when i run the following code i only get the first printed out. How do i get the complete list?
use Net::LDAP::LDIF; use Net::LDAP::Entry; $ldif = Net::LDAP::LDIF->new( "directory.ldif", "r", onerror => 'warn' + ); while( not $ldif->eof ( ) ) { $entry = $ldif->read_entry ( ); if ( $ldif->error ( ) ) { print "Error msg: ", $ldif->error ( ), "\n"; print "Error lines:\n", $ldif->error_lines ( ), "\n"; } else { print $entry->get_value("sn")."\n"; print $entry->get_value("cn")."\n"; print $entry->get_value("userPassword")."\n"; print $entry->get_value("dn")."\n"; @values = $entry->attributes; print "default: @values\n"; @values = $entry->attributes ( nooptions => 1 ); print "nooptions: @values\n"; } }
LDIF FILE:
dn: cn=Login Server (portal30_sso) cn: Login Server (portal30_sso) description: Central Authentication Authority objectClass: top objectClass: applicationProcess dn: cn=PORTAL30_SSO, cn=Login Server (portal30_sso) sn: PORTAL30_SSO cn: PORTAL30_SSO userPassword: portal30_sso objectClass: top objectClass: person dn: cn=PORTAL30_SSO_ADMIN, cn=Login Server (portal30_sso) sn: PORTAL30_SSO_ADMIN cn: PORTAL30_SSO_ADMIN userPassword: portal30_sso_admin objectClass: top objectClass: person dn: cn=PORTAL30, cn=Login Server (portal30_sso) sn: PORTAL30 cn: PORTAL30 userPassword: portal30 objectClass: top objectClass: person dn: cn=PORTAL30_ADMIN, cn=Login Server (portal30_sso) sn: PORTAL30_ADMIN cn: PORTAL30_ADMIN userPassword: portal30_admin objectClass: top objectClass: person dn: cn=PUBLIC, cn=Login Server (portal30_sso) sn: PUBLIC cn: PUBLIC userPassword: public objectClass: top objectClass: person

In reply to Read LDIF file by bodmin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.