Leser: 23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl
use strict;
use Net::LDAP;
use Net::LDAP::LDIF;
use Net::LDAP::Control::Paged;
use Net::LDAP::Constant qw(LDAP_CONTROL_PAGED);
my $ad_ldap_dn = "cn=MeinUser,ou=benutzerkonten,dc=localhost";
my $ad_ldap_password = "MeinPW";
my $ad_ldap_server = "localhost";
my $dataset = 0;
my $item;
my $ad_ldap = Net::LDAP->new($ad_ldap_server, version => 3) or die "unable to connect to ad ldap: $@";
my $result = $ad_ldap->bind($ad_ldap_dn, password => $ad_ldap_password);
my $page = Net::LDAP::Control::Paged->new(size => 1);
my $cookie;
my @args = ( base => "cn=test-gruppe,ou=zentral,ou=gruppen,dc=localhost",
scope => 'sub',
attrs => ['member'],
filter => "(objectclass=*)",
control => [ $page ]
);
while (my $ad_search = $ad_ldap->search(@args)) {
while (my $ad_user = $ad_search->shift_entry) {
foreach $item ($ad_user)
{
my $member = $item->get_value('member');
print "$member\n";
}
my ($resp) = $ad_search->control(LDAP_CONTROL_PAGED);
$cookie = $resp->cookie or last;
$page->cookie($cookie);
}
if (!$cookie) # letzter Datensatz
{
last;
}
}
$ad_ldap->unbind();
1
2
3
4
5
6
7
8
9
10
version: 1
dn: CN=test-gruppe,OU=Zentral,OU=Gruppen,DC=localhost
objectClass: top
objectClass: group
cn: test-gruppe
member: CN=user1,OU=Benutzerkonten,DC=localhost
member: CN=user2,OU=Benutzerkonten,DC=localhost
member: CN=user3,OU=Benutzerkonten,DC=localhost
member: CN=user4,OU=Benutzerkonten,DC=localhost
member: CN=user5,OU=Benutzerkonten,DC=localhost
1
2
3
srv0815:/home/user/ldap # perl ldap.pl
test-gruppe CN=user1,OU=Benutzerkonten,DC=localhost
srv0815:/home/user/ldap #
foreach my $item ($ad_user)
1 2 3 4 5
foreach $item ($ad_user) { my @members = $item->get_value('member'); print "$_\n" for @members; }
2009-10-06T14:16:53 reneeungetestet
Code (perl): (dl )1 2 3 4 5foreach $item ($ad_user) { my @members = $item->get_value('member'); print "$_\n" for @members; }