#!/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);
LDAP 系统用户uid 查找用户邮箱地址
原创bobo5620301hotm ©著作权
文章标签 perl search LDAP UI 文章分类 软件测试
©著作权归作者所有:来自51CTO博客作者bobo5620301hotm的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章