line 96 is

$ldif->write($pwarray->[$i][0]);//string
which is the first line attempting to write to the LDIF file. You appear to be trying to write a string attribute value 'username'. Net::LDAP::LDIF expects the parameter to 'write' to be a valid Net::LDAP::Entry object. You need to construct a Net::LDAP::Entry object for every LDAP object you want to create in your LDIF file, and pass that to 'write'.

Example:

use strict; use warnings; use Net::LDAP::LDIF; use Net::LDAP; my @entryvalues = qw( testuser testcn testsn ); my $entry = Net::LDAP::Entry->new(); $entry->dn("cn=".$entryvalues[1].",ou=test,dc=test,dc=com"); $entry->add( "uid" => $entryvalues[0], "cn" => $entryvalues[1], "sn" => $entry[2], "objectclass"=> "inetorgperson" ); my $ldif = Net::LDAP::LDIF->new("file.ldif","w"); $ldif->write($entry);

--------------------------------------------------------------

"If there is such a phenomenon as absolute evil, it consists in treating another human being as a thing."
John Brunner, "The Shockwave Rider".

Can you spare 2 minutes to help with my research? If so, please click here


In reply to Re: working with DBI and Net::Ldap::Ldif by g0n
in thread working with DBI and Net::Ldap::Ldif by philosophia

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.