
rfransix
Novice
Jun 22, 2010, 9:10 AM
Post #10 of 12
(2238 views)
|
Re: [FishMonger] One Line at a Time Please
[In reply to]
|
Can't Post
|
|
Grateful for you views and replies. However, we are not getting results, so, I've reverted to my original code, which actually does more of what is required. Unfortunately, the following error is preventing a successful result. Your answers are appreciated. I've declared $entry here: my $entry = $dn->pop_entry(); Thanks. I figure once the first ldap search and print statements are working, adding the 2nd ldap search will be a snap. #! 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, ">", "buildAD.ldif" or die "Cannot open 'buildAD.ldif': $!"; my $HOST = "11"; my $ADMIN = "cn=corp"; my $PWD = "0"; my $BASEDN = "dc=corp"; my $ldap = Net::LDAP->new("$HOST", port=>389) or die "$@"; my $dn = $ldap->bind("$ADMIN", password=>"$PWD"); my @attr = "1.1"; my $result = Net::LDAP::LDIF->new( "buildAD.ldif", "a", wrap=>40 ); while (<PERSON>){ chomp; $dn = $ldap->search( #return only the employeeID DN base => "$BASEDN", filter => "(&(objectClass=user)(employeeID=$_))", scope => "sub", attrs => ['1.1'] ); my $entry = $dn->pop_entry(); $result->write_entry($entry); print OUT "changetype: modify"; print OUT "replace: manager"; } $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: $!"; C:\Temp10>c:\perl\bin\perl build4aa.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 build4aa.pl line 36 at c:/Perl/site/lib/Net/LDAP/LDIF.pm line 618 Net::LDAP::LDIF::__ANON__('Net::LDAP::LDIF=HASH(0x1edb774)', '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(0x1edb774)', '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(0x1edb774)', 0, undef) called at c:/Perl/site/lib/Net/LDAP/LDIF.pm line 473 Net::LDAP::LDIF::write_entry('Net::LDAP::LDIF=HASH(0x1edb774)', undef) called at build4aa.pl line 36
|