免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1917 | 回复: 1
打印 上一主题 下一主题

perl ldap search 错误 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-13 23:19 |只看该作者 |倒序浏览
今天晚上把ldap 模块装上了,写了一个脚本来进行search,但无论怎么改条件就是等到没有这个object:
#!/usr/bin/perl -w
use Net::LDAP;

my $targetHost = '192.168.1.4';
my $targetHostPort = '12389';
my $targetUser = 'uid=xhphuyu,ou=People,dc=example,dc=com';
my $targetPassword = '123456';


my $targethost='localhost';
my $ports='12389';

# Open connection to target LDAP
my $ldap = Net::LDAP->new( $targetHost, port => $targetHostPort ) or die "Error: Could not connect to Direcotry Server: $@";
# Bind or die trying
my $mesg = $ldap->bind( $targetUser, password => $targetPassword);
#my $mesg = $ldap->bind();
$mesg->code && die "Error: Could not bind:" . $mesg->error;

# see your LDAP administrator for information concerning the
# user authentication setup at your site.
my $result = $ldap->search( base => 'ou=pepole,dc=exapmle,dc=com',filter =>"(&(uid=xhphuyu))");
#my $result = $ldap->delete('uid=bfree,ou=People,dc=example,dc=com');
$result->code && warn " Warnning: Failed to search entry: ", $result->error;
$mesg = $ldap->unbind;

那位帮忙看看是什么地方出了问题,我试了删除一条记录是没有问题的,但search总是会错,郁闷死我了:
[13/Dec/2009:23:05:39 +0800] conn=92 op=0 msgId=1 - BIND dn="uid=xhphuyu,ou=People,dc=example,dc=com" method=128 version=3
[13/Dec/2009:23:05:39 +0800] conn=92 op=0 msgId=1 - RESULT err=0 tag=97 nentries=0 etime=0 dn="uid=xhphuyu,ou=people,dc=example,dc=com"
[13/Dec/2009:23:05:39 +0800] conn=92 op=1 msgId=2 - SRCH base="ou=pepole,dc=exapmle,dc=com" scope=2 filter="(uid=xhphuyu)" attrs=ALL
[13/Dec/2009:23:05:39 +0800] conn=92 op=1 msgId=2 - RESULT err=32 tag=101 nentries=0 etime=0
[13/Dec/2009:23:05:39 +0800] conn=92 op=2 msgId=3 - UNBIND
[13/Dec/2009:23:05:39 +0800] conn=92 op=2 msgId=-1 - closing from 192.168.1.4:33608 - U1 - Connection closed by unbind client -
[13/Dec/2009:23:05:40 +0800] conn=92 op=-1 msgId=-1 - closed.

[ 本帖最后由 cduedu 于 2009-12-13 23:21 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2009-12-14 00:39 |只看该作者
原帖由 cduedu 于 2009-12-13 23:19 发表
今天晚上把ldap 模块装上了,写了一个脚本来进行search,但无论怎么改条件就是等到没有这个object:
#!/usr/bin/perl -w
use Net::LDAP;

my $targetHost = '192.168.1.4';
my $targetHostPort = '12389';
...
my $result = $ldap->search( base => 'ou=pepole,dc=exapmle,dc=com',filter =>"(&(uid=xhphuyu))");
....


Check your ldap filter operation!
LDAP filter "AND" condition's operater: (&(<attibute>)(<attribute>)...)

try this: filter => '(uid=xhphuyu)'
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP