#open a connection to LDAP my $ldap = Net::LDAP->new ( "$idvServer" ) or die "$@"; my $result = $ldap->bind ( "$idvAdmin", password => "$idvPW", version => 3 ) or die($result->error()); # open the input file open WFIDS, "<$inputFile" or die("Could not open input file."); open LOGFILE, ">>$logFile" or die("Could not open log file."); foreach $empID () { chomp($empID); # remove the newline from $line. my $filter = "(workforceID=$empID)"; $mesg = $ldap->search (base => $userBase, filter => "$filter", scope => "$scope", attrs => $userAttributes) ; $totalFound=$mesg->count; # determine the number of entries found, should only be one my @entries = $mesg->entries; if ($totalFound eq 1) { my $photo = $entries[0]->get_value('photo'); open OUTFILE, ">${outputFile}${empID}.jpg" or die("Could not create the empID file."); print OUTFILE "$photo"; close OUTFILE; print LOGFILE "Found 1 ID for $empID\n"; } else { print LOGFILE "Found more than 1 ID or found 0 IDs for $empID\n"; } } close(WFIDS); close LOGFILE; $ldap->unbind;