#!/tools/cfr/bin/perl
#this is a module that will find user's mailbox using UID:
#contact bobo5620301@163.com
#8/17/2012

sub get_mailaddress{
use Net::LDAP;
$LDAPServer = 'ldap.lsil.com';
#$argString = join("*", @ARGV);
my $ldap = Net::LDAP->new("$LDAPServer") or die "$@";
$ldap->bind ;    # an anonymous bind
 $mesg = $ldap->search (  # perform a search
  base   => "ou=lsil.com,o=lsi logic",
  filter => "| (uid=*$uid*) $extraFilter ",
  attrs  => ['mail'],
             );
$mesg->code && die $mesg->error;
my $max = $mesg->count;
for ($i =0; $i < $max; $i++) {
  my $entry = $mesg->entry($i);
# build an array of attributes
  foreach my $attr ($entry->attributes) {
    print $entry->get_value($attr),"\n";
  }
}

$ldap->unbind;   # take down session
exit;
}
$uid="ricwang";
& get_mailaddress ($uid);