Grateful for your time and expertise, I am searching for a method to resolve 
the issue with how pop_entry() is coded. I've provided the code and the error. 
Thanks. 




C:\Temp10>c:\perl\bin\perl ldif3a.pl 
Use of uninitialized value $entry in concatenation (.) or string at 
        c:/Perl/site/lib/Net/LDAP/LDIF.pm line 506, <PERSON> line 2 (#1) 
    (W uninitialized) An undefined value was used as if it were already 
    defined.  It was interpreted as a "" or a 0, but maybe it was a mistake. 
    To suppress this warning assign a defined value to your variables. 

    To help you figure out what was undefined, perl will try to tell you the 
    name of the variable (if any) that was undefined. In some cases it cannot 
    do this, so it also tells you what operation you used the undefined value 
    in.  Note, however, that perl optimizes your program and the operation 
    displayed in the warning may not necessarily appear literally in your 
    program.  For example, "that $foo" is usually optimized into "that " 
    . $foo, and the warning will refer to the concatenation (.) operator, 
    even though there is no . in your program. 

Uncaught exception from user code: 
        Entry '' is not a valid Net::LDAP::Entry object. at ldif3a.pl line 54 
 at c:/Perl/site/lib/Net/LDAP/LDIF.pm line 618 
        Net::LDAP::LDIF::__ANON__('Net::LDAP::LDIF=HASH(0x18746cc)', 'Entry 
\'\' is not a valid Net::LDAP::Entry object.') called at c:/Perl/ 
site/lib/Net/LDAP/LDIF.pm line 637 
        Net::LDAP::LDIF::_error('Net::LDAP::LDIF=HASH(0x18746cc)', 'Entry \'\' 
is not a valid Net::LDAP::Entry object.') called at c:/Perl/si 
te/lib/Net/LDAP/LDIF.pm line 506 
        Net::LDAP::LDIF::_write_entry('Net::LDAP::LDIF=HASH(0x18746cc)', 0, 
undef) called at c:/Perl/site/lib/Net/LDAP/LDIF.pm line 473 
        Net::LDAP::LDIF::write_entry('Net::LDAP::LDIF=HASH(0x18746cc)', undef) 
called at ldif3a.pl line 54 
1 
C:\Temp10>cat ldif3a.pl 
#! perl 

use strict; 
use warnings; 
use diagnostics; 

use Net::LDAP; 
use Net::LDAP::Entry; 
use Net::LDAP::Search; 
use Net::LDAP::LDIF; 



open PERSON, "<", "ou3" or die "Cannot open 'ou3': $!"; 
open MGR, "<", "ou8" or die "Cannot open 'ou8': $!"; 
open OUT, ">", "ldif3.ldif" or die "Cannot open 'ldif3.ldif': $!"; 



my $HOST = "1"; 
my $ADMIN = "DC=corp"; 
my $PWD = "20"; 
my $BASEDN = "DC=corp"; 



my $ldap = Net::LDAP->new("$HOST", port=>389) or die "$@"; 
my $dn = $ldap->bind("$ADMIN", password=>"$PWD"); 
my $mgrdn = $ldap->bind("$ADMIN", password=>"$PWD"); 
my @attr = "1.1"; 
my $result = Net::LDAP::LDIF->new( "ldif3.ldif", "a", wrap=>40 ); 
my $entry; 
my $entry2; 



while (<PERSON>){ 
chomp; 
$dn = $ldap->search( #return only the employeeID DN 
        base => "$BASEDN", 
        filter => "(&(objectClass=user)(employeeID=$_))", 
        scope => "sub", 
        attrs => ['1.1'] 
        ); 



#works fine up to here...then when pop_entry is called, error above is shown 



#        $dn->code && die $dn->error; 

#        Net::LDAP::LDIF->new( "ldif3b.ldif", "a", wrap=>40 )->write( 
$dn->entries ); 

#        foreach $entry ( $dn->entries ) {entry->dump}; 



        $entry = $dn->pop_entry; 
        print $result->write_entry($entry); 
        #next unless $dn; 
        print OUT "changetype: modify", "\n"; 
        print OUT "replace: manager", "\n"; 



#I've commented the rest of the script out until this can be resolved as it 
will do a similiar action 



#continue; 
#while ($mgr){ 
#while (<MGR>){ 
#chomp; 
#$mgrdn = $ldap->search( #return only the manager DN 
#        base => "$BASEDN", 
#        filter => "(&(objectClass=user)(employeeID=$_))", 
#        scope => "sub", 
#        attrs => [...@attr], 
#        ); 
#        $mgrdn->code && die $mgrdn->error; 
#        foreach $entry2 ($mgrdn->entries) { $entry2->dump; } 
#        #$entry2 = $mgrdn->pop_entry(); 
#        #$result->write_entry($entry2); 
#        #print OUT $entry2; 
#        #print OUT "manager: $entry2", "\n"; 
#} 
} 

$dn = $ldap->unbind;  #session ends 

close OUT or die "Cannot close in-memory file: $!"; 
close MGR or die "Cannot close in-memory file: $!"; 
close PERSON or die "Cannot close in-memory file: $!"; 

Reply via email to