如何使用 Perl 从 LDAP 检索所有组
我有一个 Perl 脚本,它绑定到 LDAP 服务器并检索所有用户。到目前为止,它运行良好,但我想过滤该搜索以收集所有组。一旦我拥有所有组,用户就可以选择这些组之一,我将只向他显示属于该组成员的用户。我该如何进行这些查询?我尝试了这个:
my $mesg = $ldap->search(
base => $base,
filter => '(objectclass=user)',
attrs => ['memberOf']
);
但是有些组会重复,我将不得不手动过滤结果(我想避免这种情况)。那么第二个查询呢?
I have a Perl script wich binds to an LDAP server and retrieves all users. So far it works good but I want to filter that search in order to gather all groups. Once I have all groups the user can select one of these groups and I'll show him only users that are member of that group. How can I do those queries? I tryed this one:
my $mesg = $ldap->search(
base => $base,
filter => '(objectclass=user)',
attrs => ['memberOf']
);
But then some groups are repeated and I will have to manually filter the result (and I'd like to avoid that). And what about the second query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
cn 获取所有组的过滤器是“
(objectclass=group)
”,您可以仅检索一个组织单位 (scope => 'one') 或所有子组织 (scope => 'sub') 中的组)有关更多帮助,请参阅 Perl-ldap 简介
编辑
如下您正在寻找的过滤器是:
cnThe filter to get all groups is "
(objectclass=group)
" you can retreive groups in only one organizationalUnit (scope => 'one') or in all suborganization (scope => 'sub')For more help see An Introduction to perl-ldap
Edited
So the filter you were looking for is :
使用 objectclass=* 获取全部。
Use objectclass=* to get all.