I tried putting in an else, but still not getting anything.
#!/usr/local/bin/perl -w
# Modules used
use Mozilla::LDAP::Conn; # Main "OO" layer for LDAP
use Mozilla::LDAP::Utils;
use Mozilla::LDAP::Entry;
use Mozilla::LDAP::API qw(:constant :api);
use Date::Calc qw(:all);
use Time::Local;
use strict;
use English;
use locale;
use FileHandle;
##############################################################
### Configuration Block #1 Dev, Test & Production Systems ###
##############################################################
my $script_log = "Migrate_functionals";
my $functional_data_file = "functional.txt";
my $pager_data_file = "pager.txt";
my $log_directory = "/usr/users/xxxx/";
my $data_directory = "/usr/users/xxxx/";
# UM connection variables
my (%ld) = Mozilla::LDAP::Utils::ldapArgs();
my (%adld) = Mozilla::LDAP::Utils::ldapArgs();
$ld{port} = 389;
$ld{root} = "ou=people,o=xxx.com,o=wcom";
$ld{base} = "ou=people,o=xxx.com,o=wcom";
$ld{scope} = "subtree";
my $UM_conn;
my @attr = ("corpid", "aliasdate", "mail");
my $um_user_type;
system ("mv $log_directory$script_log $log_directory$script_log.old");
open(LOG, ">$log_directory$script_log") || die "cannot create log f
+ile $script_log\n";
if ($ARGV[0] eq "TEST") {
$ld{host} = "xxxxxxxx.com";
$ld{bind} = "cn=xxxx";
$ld{pswd} = "xxx";
} elsif ($ARGV[0] eq "PROD") {
$ld{host} = "xxxxxx.com";
$ld{bind} = "cn=xxxxxxxx";
$ld{pswd} = "xxxx";
} else {
usage();
}
}
print "Connecting to UM...\n";
#################################################################e
# Try to connect to the LDAP directory
##################################################################
$UM_conn = new Mozilla::LDAP::Conn(\%ld);
if (!$UM_conn) {
print "UM Access failed. Exiting.";
exit;
}
###################################################################
# Look up user(s) in Directory
######################################################################
+#####
my $entry = $UM_conn->search($ld{base}, $ld{scope}, "(&(|(usertype=F)(
+usertype=P))(mail=*)(!(espid=4)))", 0, @attr);
#my $entry = $UM_conn->search($ld{base}, $ld{scope}, "(&(mail=*)(maila
+lternateaddress=*)(aliasdate=*))", 0, @attr);
if (!$entry) {
my $code = $UM_conn->getErrorCode();
if ($code == 0) {
print "No Directory records found to process on this run.\n"
} else {
print "Run terminated on LDAP Error=" . $UM_conn->getErrorStri
+ng() . ".\n";
}else {
while($entry) {
my $functional = new FileHandle;
my $pager = new FileHandle;
open(FLOG, ">>$log_directory$functional_data_file") || die "can
+not create Funtional file $functional_data_file\n";
open(PLOG, ">>$log_directory$pager_data_file") || die "cannot c
+reate Funtional file $pager_data_file\n";
if (($um_user_type =~ /F/)) {
print FLOG "$entry->{usertype}[0] - Address $entry->{mail}
+[0]\n";
}
elsif ($um_user_type =~ /P/) {
print PLOG "$entry->{usertype}[0] - Address $entry->{mail}[0]\
+n";
}
}
$UM_conn->close;
print STDERR "closing connection to UM"\n;
}
|