Original post:
Hi Perl Monks,
Trying to figure out a way to do an
my $ldif = Net::LDAP::LDIF->new( "../packages/ldapsearch.ldif", "r") or die "file not exits\n"; on the output of an
exec qx[customldapsearch_from_vendor command].
I want to use perl to process the large ldif it creates and format it into a csv report. Have most of it done, but want to be able to dynamically control the exec win32 command from perl and then immediately pass the output into the new LDAP LDIF.
Right now the exec doesn't release the file so I can than process it in perl through the ldif call and I'm getting an error when opening the file.
Thanks!!
Hi Perl Monks,
Having an issue reading in a huge LDIF with comments every 5 thousand lines, how do I ignore those when opening the ldif with net::LDAP::ldif->new?
example of LDIF with comments:
# userid2, help, perl.monks
dn: uid=userid2,ou=help,dc=perl,dc=monks
FriendlyId: crazyID2
IdCreatedOn: 28-02-2015 04:40:55
#BELOW IS THE COMMENTS PERL CHOKES ON EVERY 5k lines with LDIF MODULE
# search result
# search: 2
# result: 0 Success
control: 1.2.840.113556.1.4.319 false BLAHBLAH
# extended LDIF
#
# LDAPv3
# base <ou=help,dc=perl,dc=monks> with scope subtree
# filter: (|(Id1=*)(Id2=*))
# requesting: FriendlyId IdCreatedOn
# with pagedResults critical control: size=1000
#
# userid, help, perl.monks
dn: uid=userid,ou=help,dc=perl,dc=monks
FriendlyId: crazyID
IdCreatedOn: 28-02-2015 04:40:55
Do I have to parse these out of the ldif before reading it in with net ldap ldif?
my $ldif = Net::LDAP::LDIF->new( "../packages/ldapsearch.ldif", "r") o
+r die "file not exits\n";
while( not $ldif->eof( ) ) {
my $entry = $ldif->read_entry( );
Right now it's reading in the file it generates but only gets like a quarter of the way through it then throws an error entry not valid on the line with this: $entry = $ldif->read_entry()
Shouldn't NET LDAP LDIF conform to the
standard
UPDATE:
Never mind found out my own issue, as you can see in the comments section every 5k lines it has one un-commented line in the middle. so the ldif I'm using doesn't conform to the standard. wish I could use LDIF module to create the ldif, but need to page the results every 1k search results.
2017-12-28 Athanasius restored original content and added code tags
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.