Grateful, I return with good news. I have removed the dashes, unwrapped the search result and sent to a file (although I had to hardcode the filename. My next plea is to discover why Net::LDAP::LDIF only writes the last result to FILE, I wish all results to write to FILE. Here's the updated code.
while (<PERSON>){
chomp;
$dn = $ldap->search( #return only the employeeID DN
base => "$BASEDN",
filter => "(&(objectClass=user)(employeeID=$_))",
scope => "sub",
attrs => ['1.1']
);
Net::LDAP::LDIF->new( "buildAD.ldif", "w", wrap=>40 )->write( $dn->ent
+ries );
}
| [reply] [d/l] |
Happy, I return with more good news. I have been able to send all search results to a file. However, I wish to iteratively search on PERSON values, writing the result to FILE, as well as the print OUT statements, to build an LDIF. This is not happening. Instead, the print OUT statements are clobbering FILE, overwriting the search results. Here's the code, thanks.
while (<PERSON>){
chomp;
$dn = $ldap->search( #return only the employeeID DN
base => "$BASEDN",
filter => "(&(objectClass=user)(employeeID=$_))",
scope => "sub",
attrs => ['1.1']
);
my $result = Net::LDAP::LDIF->new( "buildAD.ldif", "a", wrap=>40 );
while( my $entry = $dn->pop_entry() )
{
$result->write_entry($entry);
}
print OUT "changetype: modify";
print OUT "replace: manager";
print OUT "manager: dn","\n";
}
$dn = $ldap->unbind; #session ends
| [reply] [d/l] |
my $ldif_OUT = 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']
);
next unless $dn; # Make sure something is returned..
while( my $entry = $dn->pop_entry() )
{
$ldif_OUT->write_entry($entry);
}
print OUT "changetype: modify";
print OUT "replace: manager";
print OUT "manager: dn","\n";
}
$dn = $ldap->unbind; #session ends
(Minimalistic error-checking added..)
Syntactic sugar causes cancer of the semicolon. --Alan Perlis
| [reply] [d/l] |
Grateful. I return with no good news. $result continues to clobber FILE, or possible print OUT clobbers FILE; either way, the desired output in an iterative format is not resolved. We pray for continued wisdom.
| [reply] |